1 2 3 Previous Next 31 Replies Latest reply on Feb 11, 2004 3:05 PM by mingdong Go to original post
      • 30. Re: delay-database-insert-until and autogenerated PKs
        robdaemon

        Argh, I've followed this and I got somewhat closer to a solution, but I get a really wierd stack trace:

        19:17:40,203 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: null, causedBy:
        javax.ejb.EJBException: Data contains multiple values, but this cmr field is single valued
        at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1129)
        at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1119)
        at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getRelatedId(JDBCCMRFieldBridge.java:983)

        I'm inserting into a table with a few relationships.

        If I look at SQL Profiler, I see some strange behavior following the INSERT statement:

        exec sp_executesql N'INSERT INTO Deployment (SubTestUnitID, BuildID, UserID, Deployed, Completed, DeployedMachine, DestinationMachineSpec) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7); SELECT SCOPE_IDENTITY()', N'@P1 int ,@P2 int ,@P3 int ,@P4 datetime ,@P5 datetime ,@P6 nvarchar(4000) ,@P7 nvarchar(4000) ', 3, 1, 1, 'Aug 12 2003 7:04:37:907PM', NULL, NULL, N'ASDF'
        exec sp_executesql N'SELECT id FROM Deployment WHERE (SubTestUnitID=@P1)', N'@P1 int ', 3

        What's really strange about this is the SELECT statement immediately after the INSERT - the INSERT is returning the new ID (the IDENTITY value) but it's still doing a SELECT, and that SELECT is trying to retrieve my primary key using a where statement on a foreign key.

        My primary key seems to be defined correctly in jbosscmp-jdbc.xml. I can post any of the files necessary if someone can _please_ help me with this. :)

        • 31. Re: delay-database-insert-until and autogenerated PKs
          mingdong

          Daniel,

          Could you post it here or send me one copy tony_cala@yahoo.com.

          Thanks

          Tony

          "dklehmann" wrote:
          Phew,

          So, finally figured out how to get auto-increment to work with MS SQL 2000 and jboss 3.2.1.

          If anyone is interested in any details, let me know.

          Thanks to Sebastien for his pointers.

          Daniel


          1 2 3 Previous Next