DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Mark Rotteveel
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Without explicit commit, fetching multiple results fails with Firebird

Created: 23/Mar/14 04:33 PM   Updated: 17/Aug/14 11:40 AM   Resolved: 12/Aug/14 04:22 PM
Component/s: Connection
Affects Version/s: 3.2.12
Fix Version/s: 4.0.2

File Attachments: 1. Zip Archive (5 kB)
2. Text File ExceptionDetails.txt (7 kB)

Jaybird 2.2.4
Firebird 2.5.2 Update 1

Datastore: Firebird

 Description  « Hide
With Jaybird 2.2.4, fetching multiple objects without an explicit transaction fails with an exception (see below and attached ExceptionDetails.txt). It looks like DataNucleus assumes that the ResultSet is HOLD_CURSORS_OVER_COMMIT which is not the default for Jaybird.

When executing the query, DataNucleus does:

1. execute query
2. check if there are results at
3. release the managed connection: at
4. When there is no explicit transaction: commit the transaction on the database connection: at$ManagedConnectionImpl.release(
5. Close the managed connection: at
6. Fetch the remaining results before physically closing the connection: at$ManagedConnectionImpl.close(

The problem starts at step 4. The transaction commit closes the ResultSet, the subsequent fetch in step 6 triggers an exception as the result set is already closed (although due to an existing bug in Jaybird this is only detected when the fetch is actually sent to the server).

To me it looks like the ManagedConnectionListener.transactionPreClose() defined at should also be called for non-managed transactions if the resultset is not holdable over commits.


mrt 23, 2014 3:44:06 PM closingConnection
INFO: Reading in results for query "SELECT FROM nl.lawinegevaar.jdo.Product WHERE price > value PARAMETERS int value" since the connection used is closing
Exception in thread "main" javax.jdo.JDOUserException: Exception thrown while loading remaining rows of query
at org.datanucleus.api.jdo.JDOAdapter.getUserExceptionForException(
at org.datanucleus.api.jdo.JDOQuery.execute(
at nl.lawinegevaar.jdo.JDOQuery.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.intellij.rt.execution.application.AppMain.main(
javax.jdo.JDODataStoreException: Failed to read the result set : GDS Exception. 335544332. invalid transaction handle (expecting explicit transaction start)
at org.datanucleus.api.jdo.JDOAdapter.getDataStoreExceptionForException(
(full stacktrace attached)

Mark Rotteveel added a comment - 23/Mar/14 04:36 PM
Simple reproduction Maven project:
* Create an empty Firebird database
* Adjust the persistence xml

Run to populate the database
Run to reproduce the problem

Mark Rotteveel made changes - 23/Mar/14 04:36 PM
Field Original Value New Value
Attachment ExceptionDetails.txt [ 12054 ]
Attachment [ 12055 ]
Andy Jefferson added a comment - 12/Aug/14 04:22 PM
GitHub master adds information to the DatastoreAdapter whether a database (JDBC) supports HOLD_CURSORS_OVER_COMMIT, and acts accordingly.

Andy Jefferson made changes - 12/Aug/14 04:22 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 4.0.2 [ 12235 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 17/Aug/14 11:40 AM
Status Resolved [ 5 ] Closed [ 6 ]