I see that both geronimo and openejb have jta or non-tx jpa query wrappers that close the entity manager after the query executes. This pretty effectively prevents the query from being re-executed.
Despite recalling having written the geronimo version, I can't remember why this is necessary. We've found someone who is doing something like this: @Stateless @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER) @TransactionManagement(TransactionManagementType.CONTAINER) @TransactionAttribute(TransactionAttributeType.REQUIRED) public class Foo implements FooLocal { @PersistenceContext(unitName="FooJpa", type = PersistenceContextType.TRANSACTION) private EntityManager em; private Query findBars; @PostConstruct void postConstruct() { findBars = em.createNamedQuery("findBars"); } public Collection<Bar> getAllBars() { return findBars.getResultList(); } } The second time getAllBars() is called, the em is closed. There are some other errors in their code which might possibly be causing this, but I think what is happening is that the postconstruct is executing outside a jta transaction, so that the findBars query is a wrapped query that closes itself after the query executes, even though it is executing in a jta environment. Should our wrapper only close the em if it is executed (rather than created) outside a jta tx? advice really appreciated :-) thanks david jencks