When calling [i]EntityManager.flush()[/i] TopLink will write the changes to the database that are currently in the PersistenceContext. In any JPA implementation the only way for a user to be sure that the current updates or inserts have been sent to the database is to force a '[i]flush()[/i]' on the EntityManager. For efficiency reasons a PersistenceProvider is permitted to queue changes until commit unless '[i]flush()[/i]' is called.
If a particular order of operations is required then the user must ensure '[i]flush()[/i]' is used to enforce that order.
'[i]flush()[/i]' if used repeatedly can be less efficient then allowing the PersistenceProvider to queue the changes until the end of the transaction but in this case the user is using '[i]flush()[/i]' to control the order and not adding a lot of overhead.
--Gordon
[Message sent by forum member 'gyorke' (gyorke)]
http://forums.java.net/jive/thread.jspa?messageID=248292