This content has been marked as final.
Show 5 replies
-
1. Re: What is the best way to re-attach a detached entity?
smokingapipe Aug 18, 2006 2:41 AM (in response to smokingapipe)Or the other option would be to remove and persist:
entityManager.remove(customer);
entityManager.persist(customer);
but that seems like it would not be a good solution. Surely this is something that comes up in nearly every Seam application, but I can't find any good suggestions on how to handle this. -
2. Re: What is the best way to re-attach a detached entity?
wolfc Aug 18, 2006 3:59 AM (in response to smokingapipe)Please try:
customer = entityManager.merge(customer);
-
3. Re: What is the best way to re-attach a detached entity?
smokingapipe Aug 18, 2006 4:03 AM (in response to smokingapipe)That's what I did, but after I do the merge, I do:
if(! entityManager.contains(customer)) {
log.severe("the entity manager is broken");
}
and of course, that log entry shows up. Does this make any sense? -
4. Re: What is the best way to re-attach a detached entity?
aidan_b5 Aug 18, 2006 5:35 AM (in response to smokingapipe)I may be wrong but is this not to do with transactions?
tryentityManager.flush()
after you've done the merge but before you query the db -
5. Re: What is the best way to re-attach a detached entity?
taras1984 Aug 18, 2006 10:18 AM (in response to smokingapipe)I think Wolfc is right.
You have to try:customer2 = entityManager.merge(customer);
notentityManager.merge(customer);
I think customer2 is merged entity when customer after those codes remains detached.