Inserting new record in table with PK columns of UUID and trigger to generate 
new UUIDs
---------------------------------------------------------------------------------------

                 Key: CAY-747
                 URL: https://issues.apache.org/cayenne/browse/CAY-747
             Project: Cayenne
          Issue Type: Improvement
          Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
         Environment: Windows XP, NetBeans 5.0, MySQL 5.0
            Reporter: Heino Grøndahl Sørensen
            Priority: Minor


I have a table with a primary key column containing UUIDs, represented as 
strings in the database.
I have added a trigger on before insert to create a new UUID, using the UUID() 
function.
I have set the PK Generation Stategy to Database-Generated and the 
Auto-incremented is set to the name of the column.
When I insert a new record into the table I get an exception on commitChanges. 
Here is an bit of the stack trace.

org.apache.cayenne.CayenneRuntimeException: [v.2.0.2 January 14 2007] One and 
only one PK row is expected, instead got 0
        at 
org.apache.cayenne.access.DataDomainFlushObserver.nextGeneratedDataRows(DataDomainFlushObserver.java:87)
        at 
org.apache.cayenne.access.DataNodeQueryAction.nextGeneratedDataRows(DataNodeQueryAction.java:79)
        at 
org.apache.cayenne.access.jdbc.BatchAction.processGeneratedKeys(BatchAction.java:265)
        at 
org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries(BatchAction.java:208)
        at 
org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.java:81)
        at 
org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:59)
        at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
        at 
org.apache.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFlushAction.java:219)
        at 
org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:141)
        at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:794)
        at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:765)
        at 
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:820)
        at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:762)
        at 
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1226)
        at 
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1130)

If I look in the actual table in the database, the record is there (!).
Seems like the trigger-assigned UUID is not read from the database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to