2 Replies Latest reply on Apr 26, 2009 10:31 PM by Brocha Strous

    Exception when querying for deleted Entites

    Brocha Strous Newbie

      Hello,
      My entity has a column containing a short. When querying for all changed entities including deletions and there have been deletions i get an exception. Same query but excluding deletions (selectDeletedEntities=false) works fine.

      @Entity
      @Audited
      public class VoBB {
       .....
       private short primaryProvider=0;
       .......
      }
      



       AuditReader reader = AuditReaderFactory.get(em);
       List things = (List) reader.createQuery()
       .forRevisionsOfEntity(VoBB.class, false, true)
       .add(AuditEntity.revisionNumber().gt(3))
       .getResultList();
      


      The Exception:
      org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.xconnect.peering.registry.VoBB.primaryProvider
      at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:106)
      at org.hibernate.envers.entities.mapper.SinglePropertyMapper.mapToEntityFromMap(SinglePropertyMapper.java:70)
      at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:116)
      at org.hibernate.envers.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:66)
      at org.hibernate.envers.entities.mapper.SubclassPropertyMapper.mapToEntityFromMap(SubclassPropertyMapper.java:65)
      at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:93)
      at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:126)
      at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:100)
      at com.xconnect.peering.test.EnversTest.allChangedVobbs(EnversTest.java:161)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
      at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.IllegalArgumentException: Can not set short field com.xconnect.peering.registry.VoBB.primaryProvider to null value
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
      at sun.reflect.UnsafeShortFieldAccessorImpl.set(UnsafeShortFieldAccessorImpl.java:62)
      at java.lang.reflect.Field.set(Field.java:657)
      at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:102)
      ... 28 more

      Thanks,
      Brocha