2 Replies Latest reply on Nov 17, 2007 4:42 AM by Mark Little

    JDBC Connection

    jantzen Newbie

      I have a stateless session bean that issues select statements returning very large result sets. Therefore, it utilizes Query.setMaxResults and setFirstResult methods to page over the set, reusing the Query object. The EntityManager that creates the Query is injected by JBoss via the PersistenceContext annotion.

      While this works fine under JBoss 4.0.5, under 4.2.1 the operation fails due to the underlying Session getting closed.

      So, it appears that the EntityManager/Session is closed after the first call to Query.getResultList(), and any subsequent operations occur on a closed Session, even though the method on the stateless session bean has not yet returned. Making the bean stateful and setting the PersistenceContext to "EXTENDED" appears to enable reuse of the Query.

      Am I correct that in a stateless session bean injected PersistenceContexts may only be used once per method invocation? Is this truly the specified behavior? This is highly counter-intuitive. With stateful beans, is the Session closed and a new one assigned via dependency injection, or left open?

      Thanks