Details
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.