0 Replies Latest reply on Aug 25, 2010 12:40 PM by Robin G

    NPE when using getter of retrieved subclass entity[Testcase]

    Robin G Newbie

      There are two test cases. Both retrieve the same entity and then try to retrieve data for a related entity. In one test the entity is retrieved just with Hibernate, and in the other it is retrieved from the latest revision via Envers. The Envers testcase throws this NPE:

       

      org.hibernate.envers.exception.AuditException: java.lang.NullPointerException
          at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:93)
          at org.hibernate.envers.entities.EntityInstantiator.addInstancesFromVersionsEntities(EntityInstantiator.java:110)
          at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:97)
          at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:114)
          at org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:111)
          at org.hibernate.envers.entities.mapper.relation.lazy.ToOneDelegateSessionImplementor.doImmediateLoad(ToOneDelegateSessionImplementor.java:62)
          at org.hibernate.envers.entities.mapper.relation.lazy.AbstractDelegateSessionImplementor.immediateLoad(AbstractDelegateSessionImplementor.java:71)
          at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176)
          at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
          at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:191)
          at my.hibertest.AttributeValue_$$_javassist_2.getAttributeValueAssignments(AttributeValue_$$_javassist_2.java)
           ...
      

       

      There are 3 classes:

      1. AttributeValue (abstract)
      2. SprocketAV (extends AttributeValue)
      3. AttributeValueAssignments (has Many-to-one relationship with AttributeValue)

       

      Data:

           I create 2 SprocketAV entities, each related to one of 2 AttributeValueAssignments.

       

      Crash:

           I retrieve an AttributeValueAssignment, and try to retrieve data about its associated SprocketAV.

       

      I'm using Hibernate3.5.4 with Hibernate.cfg.xml and Hibernate Mappings XML.