[ 
https://issues.apache.org/jira/browse/OPENJPA-2789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Wolfgang Rupprath updated OPENJPA-2789:
---------------------------------------
    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.

 

  was:
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.

 


> JDBC connection not closed when running named query in explicitly opened 
> connection
> -----------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2789
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2789
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 2.4.3
>         Environment: Windows 7, Java 8 64 Bit, openJPA 2.4.3, maven 3.6.1
>            Reporter: Wolfgang Rupprath
>            Priority: Critical
>         Attachments: jpa243bug.zip
>
>
> 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.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to