Results 1 to 1 of 1
- 04-22-2011, 08:22 PM #1
JPA/JPA2: please tell me if I understand this correctly.
If I understand what I've been reading, entities can be detached from one EntityManager and merged into the persistence context of the same or a different EM. So multiple threads could conceivably operate on detached objects using ordinary Java synchronization, and then merge their changes later.
I know there are a few things to watch out for if I do this. First, if I use lazy fetch and don't access all references before detaching my entities, they could contain unresolved references. This could result in exceptions if I access those references, or corrupt data if I merge an entity containing an unresolved (null) reference. Also, merging does not make an entity managed; it returns a new, managed copy of the entity. So I'll have to be careful not to have multiple entities containing different versions of the same data.
Anything else I should be aware of?
- By phixion in forum New To JavaReplies: 9Last Post: 01-27-2011, 05:13 AM
- By LostinJavaLand in forum New To JavaReplies: 4Last Post: 07-15-2010, 06:49 AM
- By TimHuey in forum New To JavaReplies: 4Last Post: 04-24-2010, 05:54 AM
- By lat3ncy in forum New To JavaReplies: 1Last Post: 03-04-2010, 03:45 AM
- By h9h in forum Java 2DReplies: 10Last Post: 10-29-2009, 07:06 AM