[jboss-user] [JBoss Seam] - Re: Fundamental question about em.persist
do-not-reply at jboss.com
Thu Dec 13 13:51:52 EST 2007
"JUnkie" wrote : I always managed to avoid entity updates after a persist in the same method call...
May I ask why? By itself persist() doesn't necessarily triggers DB call, just introduces the object to the persistence context. If I make an update later, should be fine, the important thing is that all changes are flushed before the transaction commits.
anonymous wrote :
| however what happens if you add
| card = entityManager.merge(card);
| directly after the persist call?
Nothing changes. The same "old" record in the DB.
Now again, after persist() finishes the object is already in the persistent context, unless it is wrapped in some sort of dynamic proxy object which is later saved into the DB instead of the original object.
However I don't recall anything anywhere that would mention calling persist() the last method in your transaction, so to avoid changes between persist() and transaction commit.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112681#4112681
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112681
More information about the jboss-user