Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2789

JDBC connection not closed when running named query in explicitly opened connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.4.3
    • 3.2.0
    • jdbc, kernel
    • None
    • Windows 7, Java 8 64 Bit, openJPA 2.4.3, maven 3.6.1

    Description

      When executing a named query against a database within an explicitly opened transaction, after 10 successful executions the program hangs.

      The problem occured when we started migrating from openJPA 2.2.0 to 2.4.3

      I have tested against DB2 and Oracle databases with the same results. I suspect the problem arises for any relational DB.

      I have attached a simple maven project that will demonstrate the bug.

      Under 2.2.0, the test runs fine.

      When the query is changed to a native query, the test runs fine.

      Debugging the openJPA code, I found suspicious code in class org.apache.openjpa.jdbc.kernel.JDBCStoreQuery, method executeBulkOperation, line 587:

                  try {
               if (conn.getAutoCommit())
                             conn.close();
               } catch (SQLException se) {}{{}}

      The connection in case will not be returned to the pool as the conn.close() is not executed wthin a transaction. So when committing, the ref count will not be zero when the transaction ends and the underlying JDBC connection will not be closed.

       

      Attachments

        1. jpa243bug.zip
          5 kB
          Wolfgang Rupprath

        Activity

          People

            struberg Mark Struberg
            wrupprath Wolfgang Rupprath
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: