[i]Note, that if you use UserTransaction with a Container Managed EMF, an EM created from such EMF might need to join the transaction if such transaction began after the EM has been created:[/i]
I'm confused by this. The javadoc for that method says "This method should be called on a JTA [b]application managed EntityManager[/b] that was created outside the scope of the active transaction." Whereas you say that an EM one makes from a [b]container-managed EMF[/b] should do it.
Is the javadoc in conflict with what you wrote? Or is an EM considered application-managed even if it sprung from a container-managed EMF by way of emf.createEntityManager()?
http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#joinTransaction()
[i]Now, if EM2 has an EXTENDED persistence context, and that entity has been already loadded by EM2 in a previous transaction, its values will not get updated, unless either a) em.refresh() is called on that entit, b) em.clear() is called prior to accessing the entity again, or c) provider-specific hints used in the JPQL query.[/i]
Are EXTENDED persistence contexts the default? Nowhere does my application specify the persistence context type.
Here's some observations that stemmed from your suggestion, though: calling em.refresh() on the selecting code did, indeed, act as a workaround for the stale data issues I'm seeing.
I also tried em.clear() prior to the select. That, by itself, made no difference however.
[Message sent by forum member 'pohl' (pohl)]
http://forums.java.net/jive/thread.jspa?messageID=208816