OpenJPA
  1. OpenJPA
  2. OPENJPA-1957

XML overriding column names for ArrayList attributes causes exception.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.2, 2.0.1, 2.1.0
    • Fix Version/s: 1.2.3, 2.0.2, 2.1.1, 2.2.0
    • Component/s: jdbc
    • Labels:
      None

      Description

      Take an entity class similar to the following:

      public class MyEntity implements Serializable {
      protected String _id;
      protected ArrayList<String> myStrings = new ArrayList<String>();
      .......

      and a corresponding XML mapping in orm.xml:

      <entity class="somepackage.MyEntity" access="FIELD">
      <table name="MY_TABLE"/>
      <attributes>
      <id name="_id">
      <column name="MYENTITY_ID" nullable="false" />
      </id>
      <basic name="myStrings">
      <column name="MY_STRINGS"/>
      <lob/>
      </basic>
      </attributes>
      </entity>

      With this configuration, the following exception can occur:

      org.apache.openjpa.persistence.ArgumentException: You have supplied columns for "somepackage.MyEntity.myStrings<element:class java.lang.String>", but this mapping cannot have columns in this context.
      at org.apache.openjpa.jdbc.meta.MappingInfo.assertNoSchemaComponents(MappingInfo.java:327)
      at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:77)
      at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:121)
      at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80)
      at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:454)
      at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:419)
      at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:881)
      at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:418)
      ..............

        Issue Links

          Activity

          Hide
          Michael Dick added a comment -

          I'd need to see the testcase to comment. From memory, there's nothing functionally different between the changes in 1.2.x or any other release. The annotation parser class was refactored for new annotations in JPA 2.0 and I just slotted this code around that.

          Show
          Michael Dick added a comment - I'd need to see the testcase to comment. From memory, there's nothing functionally different between the changes in 1.2.x or any other release. The annotation parser class was refactored for new annotations in JPA 2.0 and I just slotted this code around that.
          Hide
          Heath Thomann added a comment -

          Hi! I have a test (to be included) where I see the same exception which was fixed via this JIRA:

          <openjpa-1.2.3-SNAPSHOT-r422266:1176024 fatal user error> org.apache.openjpa.persistence.ArgumentException: You have supplied columns for "org.apache.openjpa.persistence.arrays.model.XMLOneToManyEntity.xmlManyToOneList", but this mapping cannot have columns in this context.
          at org.apache.openjpa.jdbc.meta.MappingInfo.assertNoSchemaComponents(MappingInfo.java:327)
          at org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy.map(RelationToManyTableFieldStrategy.java:96)
          at org.apache.openjpa.jdbc.meta.strats.RelationCollectionTableFieldStrategy.map(RelationCollectionTableFieldStrategy.java:94)
          at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:121)
          at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80)
          at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:454)
          at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:419)
          at org.apache.openjpa.jdbc.meta.ClassMapping.resolveMapping(ClassMapping.java:855)
          at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1651)
          at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:812)
          at org.apache.openjpa.meta.MetaDataRepository.resolveMapping(MetaDataRepository.java:772)
          at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:650)
          at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:393)
          at org.apache.openjpa.meta.MetaDataRepository.getMetaDataLocking(MetaDataRepository.java:366)
          at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:360)
          at org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:356)
          at org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676)
          at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748)
          at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646)
          at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:153)
          at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
          at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
          at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
          at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
          at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
          at org.apache.openjpa.persistence.arrays.TestXMLOneToManyEntity.testExceptionArrayAsLob(TestXMLOneToManyEntity.java:34)
          .......................

          I see the same exception when I run my test on trunk. The kicker is, if I back out the changes made in this JIRA, on both 1.2.x and trunk, my test passes!! Of course, with the code changes backed out, the test Mike created for the JIRA fails. So something is not quite right/complete about this fix.

          Attached is a test, named "XMLMappingIssue-trunk.test" which you can simply apply to any OpenJPA release. I'd assume that if we fix this issue on trunk the same fix would apply to 1.2.x........although, the fix Mike made to 1.2.x is for some reason a bit different than the one he made to trunk so we may want to keep this in mind and become familiar with the differences.

          Does anyone have any thoughts here?

          Thanks,

          Heath

          Show
          Heath Thomann added a comment - Hi! I have a test (to be included) where I see the same exception which was fixed via this JIRA: <openjpa-1.2.3-SNAPSHOT-r422266:1176024 fatal user error> org.apache.openjpa.persistence.ArgumentException: You have supplied columns for "org.apache.openjpa.persistence.arrays.model.XMLOneToManyEntity.xmlManyToOneList", but this mapping cannot have columns in this context. at org.apache.openjpa.jdbc.meta.MappingInfo.assertNoSchemaComponents(MappingInfo.java:327) at org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy.map(RelationToManyTableFieldStrategy.java:96) at org.apache.openjpa.jdbc.meta.strats.RelationCollectionTableFieldStrategy.map(RelationCollectionTableFieldStrategy.java:94) at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:121) at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80) at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:454) at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:419) at org.apache.openjpa.jdbc.meta.ClassMapping.resolveMapping(ClassMapping.java:855) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1651) at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:812) at org.apache.openjpa.meta.MetaDataRepository.resolveMapping(MetaDataRepository.java:772) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:650) at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:393) at org.apache.openjpa.meta.MetaDataRepository.getMetaDataLocking(MetaDataRepository.java:366) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:360) at org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:356) at org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676) at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748) at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646) at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:153) at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.arrays.TestXMLOneToManyEntity.testExceptionArrayAsLob(TestXMLOneToManyEntity.java:34) ....................... I see the same exception when I run my test on trunk. The kicker is, if I back out the changes made in this JIRA, on both 1.2.x and trunk, my test passes!! Of course, with the code changes backed out, the test Mike created for the JIRA fails. So something is not quite right/complete about this fix. Attached is a test, named "XMLMappingIssue-trunk.test" which you can simply apply to any OpenJPA release. I'd assume that if we fix this issue on trunk the same fix would apply to 1.2.x........although, the fix Mike made to 1.2.x is for some reason a bit different than the one he made to trunk so we may want to keep this in mind and become familiar with the differences. Does anyone have any thoughts here? Thanks, Heath

            People

            • Assignee:
              Michael Dick
              Reporter:
              Heath Thomann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development