[OS-JIRA] Created: (CAY-341) Failing to insert into two different tables with identity primary keys on mssql within a single transaction

From: jira-norepl..bjectstyle.org
Date: Thu Jun 30 2005 - 04:03:35 EDT


Message:

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:

  http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-341

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: CAY-341
    Summary: Failing to insert into two different tables with identity primary keys on mssql within a single transaction
       Type: Bug

     Status: Assigned
   Priority: Major

    Project: Cayenne
 Components:
             Cayenne Core Library
   Versions:
             1.2 [DEV]

   Assignee: Andrus Adamchik
   Reporter: Rudolf

    Created: Thu, 30 Jun 2005 4:03 AM
    Updated: Thu, 30 Jun 2005 4:03 AM
Environment: WIN XP PRO, JDK 1.5, Tomcat 5.59, MSSQL 2000 on WIN 2K

Description:
During inserting data into more then one different tables with enabled database pk-autogeneration (Identity YES, Identity Seed 1, Identity Increment 1) within an transaction accures a db-exception:
##############################################
2005-06-30 09:23:26,818 [DEBUG] org.objectstyle.cayenne.access.ContextCommit.Creating InsertBatchQuery for DbEntity tblEffBlockConfig
2005-06-30 09:23:26,834 [DEBUG] org.objectstyle.cayenne.access.ContextCommit.Creating InsertBatchQuery for DbEntity tblLoggerConfig
2005-06-30 09:23:26,834 [INFO ] org.objectstyle.cayenne.access.QueryLogger.--- transaction started.
2005-06-30 09:23:26,834 [INFO ] org.objectstyle.cayenne.access.QueryLogger.--- will run 2 queries.
2005-06-30 09:23:26,834 [INFO ] org.objectstyle.cayenne.access.QueryLogger.SET IDENTITY_INSERT dbo.tblEffBlockConfig ON
2005-06-30 09:23:26,834 [INFO ] org.objectstyle.cayenne.access.QueryLogger.INSERT INTO dbo.tblEffBlockConfig (effBlockConfigId, efficiencyBlockNumber, loggerId, propertyKey, propertyValue) VALUES (?, ?, ?, ?, ?)
2005-06-30 09:23:26,849 [INFO ] org.objectstyle.cayenne.access.QueryLogger.[bind: 220, 1, 1, 'TESTKEY', 'TESTVALUE']
2005-06-30 09:23:26,849 [INFO ] org.objectstyle.cayenne.access.QueryLogger.=== updated 1 row.
2005-06-30 09:23:26,849 [INFO ] org.objectstyle.cayenne.access.QueryLogger.SET IDENTITY_INSERT dbo.tblLoggerConfig ON
2005-06-30 09:23:26,865 [INFO ] org.objectstyle.cayenne.access.QueryLogger.*** error.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]IDENTITY_INSERT is already ON for table 'dbSunreader2RUB.dbo.tblEffBlockConfig'. Cannot perform SET operation for table 'dbo.tblLoggerConfig'.
        at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
        at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
        at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
        at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
        at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
        at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.executeInternal(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.execute(Unknown Source)
        at org.objectstyle.cayenne.dba.sqlserver.SQLServerDataNode.runBatchUpdate(SQLServerDataNode.java:109)
        at org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:353)
        at org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:192)
        at org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1266)
        at org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:1236)
#################################
Seems to be a bug, cause only one table in a session is allowed to have set the property IDENTITY_INSET to ON. After the insert into such table this property should be set to OFF otherwise no insert into a second table is possible.

---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://objectstyle.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



This archive was generated by hypermail 2.0.0 : Thu Jun 30 2005 - 04:03:40 EDT