cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAY-1746) Two InsertBatchQueries generated for a single DbEntity insert when this DbEntity has a flattened attribute and a flattened relationship
Date Tue, 09 Oct 2012 18:42:04 GMT

     [ https://issues.apache.org/jira/browse/CAY-1746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andrus Adamchik updated CAY-1746:
---------------------------------

    Attachment: vinheritance.tar.gz
    
> Two InsertBatchQueries generated for a single DbEntity insert when this DbEntity has
a flattened attribute and a flattened relationship 
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAY-1746
>                 URL: https://issues.apache.org/jira/browse/CAY-1746
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B1
>            Reporter: Andrus Adamchik
>         Attachments: vinheritance.tar.gz
>
>
> This often happens when vertical inheritance is in use:
> T1: ID (PK)
> T2: ID (dependent PK), T3_ID, T2_COL 
> T3: ID (PK)
> abstract class O1 // maps to T1
> class O2 extends O1 // maps to T1
>    O3 o3; // maps to 't2.t3'
>    Object t2Col; maps to T2_COL
> class O3 // maps to T3   
> Saving O2 together with related O3 results in 2 InsertNatchQuery instances generated
for T2. One originating from DataDomainFlattenedBucket and containing propagated PK and FK,
another - from DataDomainInsertBucket and containing T2_COL changes. 
> Depending on their (random from what I can tell), a different error would occur. Either
a NULL for PK/FK, or duplicate PK. E.g. see the attached example (a reworked version of CAY-1744
with the hack to disable read-only rels). It generates the following inserts and the following
error:
> INFO: INSERT INTO "session" ("id", "type") VALUES (?, ?)
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
> INFO: [batch bind: 1->id:200, 2->type:'c']
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logUpdateCount
> INFO: === updated 1 row.
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
> INFO: INSERT INTO "device" ("id") VALUES (?)
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
> INFO: [batch bind: 1->id:200]
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logUpdateCount
> INFO: === updated 1 row.
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
> INFO: INSERT INTO "client_session" ("device_id", "id", "ip") VALUES (?, ?, ?)
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
> INFO: [batch bind: 1->device_id:NULL, 2->id:200, 3->ip:NULL]
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logUpdateCount
> INFO: === updated 1 row.
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
> INFO: INSERT INTO "client_session" ("device_id", "id", "ip") VALUES (?, ?, ?)
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
> INFO: [batch bind: 1->device_id:200, 2->id:200, 3->ip:NULL]
> Oct 9, 2012 9:26:02 PM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryError
> INFO: *** error.
> java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because
it would have caused a duplicate key value in a unique or primary key constraint or unique
index identified by 'SQL121009212602580' defined on 'client_session'.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message