Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1557

Vertical inheritance is broken for subclasses with more than one flattened attribute

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1M3
    • 3.0.2, 3.1M3
    • Core Library
    • None

    Description

      In vertical inheritance mapping model, children objects with multiple flattened attributes are handled incorrectly while inserting in database. Cayenne is trying to do as many duplicated INSERTs in children tables as number of flattened attributes in subclass. As example, attached testcase fails with next log messages:

      INFO: — transaction started.
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
      INFO: INSERT INTO IV_ROOT (DISCRIMINATOR, ID, NAME) VALUES (?, ?, ?)
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
      INFO: [bind: 1->DISCRIMINATOR:'IvSub2', 2->ID:203, 3->NAME:'XyZX']
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logUpdateCount
      INFO: === updated 1 row.
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
      INFO: INSERT INTO IV_SUB2 (ID, SUB2_ATTR, SUB2_NAME) VALUES (?, ?, ?)
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
      INFO: [bind: 1->ID:203, 2->SUB2_ATTR:NULL, 3->SUB2_NAME:NULL]
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logUpdateCount
      INFO: === updated 1 row.
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryParameters
      INFO: [bind: 1->ID:203, 2->SUB2_ATTR:NULL, 3->SUB2_NAME:NULL]
      Apr 11, 2011 10:42:25 AM org.apache.cayenne.log.CommonsJdbcEventLogger logQueryError
      INFO: *** error.
      java.sql.SQLException: Unique constraint violation: SYS_IDX_76 in statement [INSERT INTO IV_SUB2 (ID, SUB2_ATTR, SUB2_NAME) VALUES (?, ?, ?)]
      at org.hsqldb.jdbc.Util.throwError(Unknown Source)
      at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
      at org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries(BatchAction.java:205)
      at org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.java:86)
      at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:87)
      at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:254)
      at org.apache.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFlushAction.java:226)
      at org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:144)
      at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:796)
      at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:763)
      at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:822)
      at org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:760)
      at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync(DataDomain.java:966)
      at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:731)
      at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:811)
      at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:750)
      at org.apache.cayenne.access.VerticalInheritanceTest.testInsert_Sub2(VerticalInheritanceTest.java:139)
      ...

      Attachments

        1. vertical_inheritance_duplicated_inserts_test.patch
          5 kB
          Victor Antonovich
        2. vertical_inheritance_duplicated_inserts.patch
          1 kB
          Victor Antonovich
        3. vertical_inheritance_duplicated_inserts_test1.patch
          5 kB
          Victor Antonovich
        4. vertical_inheritance_update_subclass_attrs.patch
          0.8 kB
          Victor Antonovich

        Activity

          People

            Unassigned Unassigned
            kapyar Victor Antonovich
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: