You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Matt Watson (JIRA)" <ji...@apache.org> on 2016/10/25 21:01:01 UTC

[jira] [Commented] (CAY-1746) Two InsertBatchQueries generated for a single DbEntity insert when this DbEntity has a flattened attribute and a flattened relationship

    [ https://issues.apache.org/jira/browse/CAY-1746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15606466#comment-15606466 ] 

Matt Watson commented on CAY-1746:
----------------------------------

[~andrus] was this resolved by our fix in CAY-2122 ?

> 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
>             Fix For: Short term future
>
>         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 was sent by Atlassian JIRA
(v6.3.4#6332)