Hi,
You are correct, the schema tool does assume the use of auto commit on the
connection.  The SchemaTool uses auto commit since no other transaction is
in use.  According to the Derby JIRA you referenced [1], this auto commit
usage is only supposed to be prevented in a global transaction.  And, since
there is no global transaction in effect when using the SchemaTool, this
would seem to be a problem with the Derby JDBC4 driver code.

I am only going off what was in the Derby JIRA.  The JIRA says global
transaction as the gating factor, while your note mentions an XA-capable
data source as the gating factor for auto commit.  I have not found the
exact reference in the JDBC4 spec that outlines this.  But, at this point,
it sounds like a problem with the Derby JDBC4 driver.

Kevin

On Tue, Feb 16, 2010 at 4:51 PM, akarypid <[email protected]> wrote:

>
> Hello,
>
> I'm a new user trying out OpenJPA and I've come across what seems to be a
> bug:
>
> When generating the schema for a persistence context, OpenJPA seems to use
> auto-commit mode. However, the JDBC4 spec explicitly prohibits auto-commit
> for XA-capable data source. Therefore, if you happen to use an XA driver, a
> proper JDBC implementation would cause OpenJPA.
>
> This is exactly what happened when I tried OpenJPA: I'm using OpenJPA 1.2.1
> with Derby Embedded 10.4.2.0 (both from Geronimo 2.2 distribution).
>
> Derby performs the check for auto-commit mode (see
> http://issues.apache.org/jira/browse/DERBY-1236) and aborts. The stack
> trace
> looks like:
>
> Caused by: java.sql.SQLException: Cannot set AUTOCOMMIT ON when in an XA
> connection.
>        at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> Source)
>        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
>        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
>        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
> Source)
>        at org.apache.derby.jdbc.EmbedXAConnection.checkAutoCommit(Unknown
> Source)
>        at
> org.apache.derby.iapi.jdbc.BrokeredConnection.setAutoCommit(Unknown
> Source)
>        at
>
> org.tranql.connector.jdbc.ManagedXAConnection.localTransactionCommit(ManagedXAConnection.java:104)
>        at
>
> org.tranql.connector.AbstractManagedConnection$LocalTransactionImpl.commit(AbstractManagedConnection.java:199)
>        at
>
> org.tranql.connector.jdbc.ConnectionHandle.setAutoCommit(ConnectionHandle.java:160)
>        at
>
> org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:198)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1175)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:949)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:526)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
>        at
> org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
>        at
> org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
>        ... 69 more
> Caused by: java.sql.SQLException: Cannot set AUTOCOMMIT ON when in an XA
> connection.
>        at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
>        at
>
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
> Source)
>        ... 85 more
>
> Is this indeed a bug?
>
> --
> View this message in context:
> http://n2.nabble.com/Schema-generation-uses-auto-commit-mode-breaks-on-XA-data-sources-tp4583095p4583095.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Reply via email to