You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2012/10/09 20:36:03 UTC
[jira] [Created] (CAY-1746) Two InsertBatchQueries generated for a
single DbEntity insert when this DbEntity has a flattened attribute and a
flattened relationship
Andrus Adamchik created CAY-1746:
------------------------------------
Summary: 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
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
[jira] [Updated] (CAY-1746) Two InsertBatchQueries generated for a
single DbEntity insert when this DbEntity has a flattened attribute and a
flattened relationship
Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrus Adamchik updated CAY-1746:
---------------------------------
Fix Version/s: 3.2M1
> 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: 3.2M1
>
> 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
[jira] [Updated] (CAY-1746) Two InsertBatchQueries generated for a
single DbEntity insert when this DbEntity has a flattened attribute and a
flattened relationship
Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
[ 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