0 Replies Latest reply on Jan 23, 2007 2:22 AM by jantzen

    SessionException: session closed after very large native que

    jantzen Newbie

      Hi All,

      I've got a PostgreSQL 8.1 database that I'm performing a series of large queries on under JBoss 4.0.5, and the EntityManager is closing after each query such that the next fails. The queries are native SQL, and return in excess of 250,000 rows.

      The datasource is defined as non-transactional to avoid transaction timeouts:

       <no-tx-datasource>
       <jndi-name>MyDB</jndi-name>
       <connection-url>jdbc:postgresql://localhost:5432/MyDB</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>...</user-name>
       <password>...</password>
       </no-tx-datasource>
      


      And a suspect persistence unit:

       <persistence-unit name="MyDB">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/MyDB</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
       <property name="hibernate.show_sql" value="false" />
       </properties>
       </persistence-unit>
      


      The thing that's suspect here is the jta-data-source element, when I need this datasource not to be transactional, and I should be using non-jta-data-source. Unfortunately, there's a bug that prevents me from doing that (http://jira.jboss.com/jira/browse/EJBTHREE-433)

      The EntityManager is injected by JBoss using PersistenceContext, and what I find is that the first query to run will succeed, and get through all of the expected data, but the next query to run will generate a SessionException because the EntityManager is getting shutdown somewhere.

      So, has anyone else encountered this kind of behavior? Is it likely due to the jta-data-source declaration?

      Thanks.