• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling JPA commit failures

 
Eric Jones
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about handling JPA commit failures.

It's my understanding that the general idea is to

1) Accumulate the changes in an EntityManager
2) Merge the changes into a new EntityManager, then attempt commit in the new EM
3) If it fails, the original EM is still valid, and corrections can be made there.

This sounds good. But, I'm a bit confused as to how to do the merging of step #2. Do I have to track all of the changes?

Any example code (or other suggestions) for this?

Thanks
Eric

 
Ramon Anger
Ranch Hand
Posts: 56
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you do not have to track all your changes. That's way you use the entity manager.
A simple example how to use merge() can be found at http://blog.newitfarmer.com/j2ee/hibernate/602/jpa-entitymanager-why-use-persist-over-merge/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic