Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

em.merge Persistence Issue

Sri Datta
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a fairly standard code like this.

And in Action Class, I have two methods each of which corresponds to two buttons in the page.

1) I am saving a child by clicking a button and thus invoking saveChild(). -----I have observed that changes are saved in database.

2) I am saving Parent by clicking another button and thus invoking updateParent(). -----I have observed that the previously persisted changes are still in database

3) Now when I try to save another child by invoking saveChild(), the previously saved changes are overwritten resulting in newly saved changes only.

When I try to inspect the Parent object before it is sent for em.merge in Step(3), it still has all the proper data (I mean I can see both saved childs).

If I try the above steps in the order (1),(3),(2) everything is absolutely fine. Please help me understand this issue.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!