3 Replies Latest reply on Dec 1, 2009 2:34 AM by adamw

    1.2.2 snapshot: NPE while processing configuration of the cl

      Hello,

      After switching from 1.2.1 GA to the latest 1.2.2 snapshot (25.11.2009) I get NPE if a mapping with composite-id is present in configuration. The classes with composite-id are not audited. It seems that in 1.2.1 this coding was executed only for audited classes. In 1.2.2 all mapped classes go through it. At least in my case for all 3 classes with composite-id that I have PersistentClass.getIdentifierProperty() returns null which causes NPE in IdMetadataGenerator.addId.


      Call stack:

      Exception in thread "main" java.lang.NullPointerException
      at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:96)
      at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:351)
      at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:91)
      at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:86)
      at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
      at com.softgenic.database.HibernateHelper.initialise(HibernateHelper.java:111)
      at com.softgenic.database.HibernateHelper.initialise(HibernateHelper.java:36)
      at com.softgenic.launch.SchemaGenerate.main(SchemaGenerate.java:14)

        • 1. Re: 1.2.2 snapshot: NPE while processing configuration of th
          adamw

          Hello,

          yes, that's right, all classes have the id-mapper generated, because of the new possibility to audit relations to non-audited entities.

          Could you post your mapping, so that I could reproduce the problem? Composite IDs should normally work fine, so you must have something special :)

          Adam

          • 2. Re: 1.2.2 snapshot: NPE while processing configuration of th

            Hello, Adam,

            Below are composite-id mappings for all 3 classes. At least the last one is very simple. Maybe it has to do with the way I build configuration? Probably calling buildMappings is not enough and hibernate doesn't initialize internal meta-data for composite ids?

            configuration = new AnnotationConfiguration();
             configuration.addProperties(hibernateProperties);
             // add resource files
             for (String resource : allMappingResources) {
             configuration.addResource(resource);
             }
             for(Class<? extends Object> item : allAnnotatedClasses){
             configuration.addAnnotatedClass(item);
             }
             // in order to configure envers tables main configuration has to be built before
             configuration.buildMappings();
             // configure envers
             AuditConfiguration.getFor(configuration);
            

            Class 1:
            <composite-id unsaved-value="any">
             <key-many-to-one name="accountGroup" access="field"
             class="com.loanworkbench.persist.LoanAccountGroup">
             <column name="group_uuid" not-null="true" sql-type="char(32)"/>
             </key-many-to-one>
             <key-property name="number" access="field" type="integer" column="`number`"/>
            </composite-id>


            Class 2

            <composite-id unsaved-value="any">
             <key-many-to-one name="partner" access="field" class="com.loanworkbench.data.partner.Partner">
             <column name="partner_uuid" not-null="true" sql-type="char(32)"/>
             </key-many-to-one>
             <key-many-to-one name="branch" access="field" class="com.softgenic.data.Branch" foreign-key="pbranch_fk">
             <column name="branch_uuid" sql-type="char(32)" not-null="true"/>
             </key-many-to-one>
            </composite-id>


            Class 3:

            <composite-id>
             <key-property name="objectNumberId" access="field" column="object_num" length="10"/>
             <key-property name="structureId" access="field" column="structure" length="6"/>
             <key-property name="sectionId" access="field" column="section" length="6"/>
             <key-property name="parameterValue" access="field" column="param_value" length="40"/>
            </composite-id>



            • 3. Re: 1.2.2 snapshot: NPE while processing configuration of th
              adamw

              Hello,

              I just deployed a new snapshot with a check for supported id mappings so this should now work.

              Thanks for the beta-testing :)

              Adam