java.lang.NullPointerException

Hibernate JIRA | Nguyen Hau Giang | 1 decade ago
  1. 0

    entities: RootEntity -> Entity1(cascade one to many) -> Entity2(cascade one to many) In Entity1 and Entity2, there is a user type that load Prefix data based on its prefix property. Because this user type read prefix data based on its property, in nullSafeGet(), we have to create a Criteria of Entity1(or Entity2) to get its prefix data. In case that rootEntity has multiple casecade one-to-many as above, when delete rootEntity, NullPointerException will be thrown. If there is only 1 cascade one to many property, the deletion is OK. I think this is a detail case, please see more in attache test case. PS: Test case is a simplified version of our real domain, beacause of many reasons, we cannot map Prefix as association entity(property-ref). exception log: java.lang.NullPointerException at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.java:87) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48) at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:134) at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:197) at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:189) at org.hibernate.engine.Cascades.getAllElementsIterator(Cascades.java:974) at org.hibernate.engine.Cascades.access$100(Cascades.java:33) at org.hibernate.engine.Cascades$1.getCascadableChildrenIterator(Cascades.java:72) at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:893) at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792) at org.hibernate.engine.Cascades.cascade(Cascades.java:720) at org.hibernate.engine.Cascades.cascade(Cascades.java:847) at org.hibernate.engine.Cascades.cascade(Cascades.java:819) at org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:248) at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:201) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:109) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:579) at test.base.TestBase.delete(TestBase.java:109)

    Hibernate JIRA | 1 decade ago | Nguyen Hau Giang
    java.lang.NullPointerException
  2. 0

    entities: RootEntity -> Entity1(cascade one to many) -> Entity2(cascade one to many) In Entity1 and Entity2, there is a user type that load Prefix data based on its prefix property. Because this user type read prefix data based on its property, in nullSafeGet(), we have to create a Criteria of Entity1(or Entity2) to get its prefix data. In case that rootEntity has multiple casecade one-to-many as above, when delete rootEntity, NullPointerException will be thrown. If there is only 1 cascade one to many property, the deletion is OK. I think this is a detail case, please see more in attache test case. PS: Test case is a simplified version of our real domain, beacause of many reasons, we cannot map Prefix as association entity(property-ref). exception log: java.lang.NullPointerException at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.java:87) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48) at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:134) at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:197) at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:189) at org.hibernate.engine.Cascades.getAllElementsIterator(Cascades.java:974) at org.hibernate.engine.Cascades.access$100(Cascades.java:33) at org.hibernate.engine.Cascades$1.getCascadableChildrenIterator(Cascades.java:72) at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:893) at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792) at org.hibernate.engine.Cascades.cascade(Cascades.java:720) at org.hibernate.engine.Cascades.cascade(Cascades.java:847) at org.hibernate.engine.Cascades.cascade(Cascades.java:819) at org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:248) at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:201) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:109) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:579) at test.base.TestBase.delete(TestBase.java:109)

    Hibernate JIRA | 1 decade ago | Nguyen Hau Giang
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache()
    2. Hibernate
      PersistentSet.iterator
      1. org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.java:87)
      2. org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48)
      3. org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
      4. org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
      5. org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
      6. org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:134)
      6 frames
    3. Hibernate
      Cascades.cascade
      1. org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:197)
      2. org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:189)
      3. org.hibernate.engine.Cascades.getAllElementsIterator(Cascades.java:974)
      4. org.hibernate.engine.Cascades.access$100(Cascades.java:33)
      5. org.hibernate.engine.Cascades$1.getCascadableChildrenIterator(Cascades.java:72)
      6. org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:893)
      7. org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
      8. org.hibernate.engine.Cascades.cascade(Cascades.java:720)
      9. org.hibernate.engine.Cascades.cascade(Cascades.java:847)
      10. org.hibernate.engine.Cascades.cascade(Cascades.java:819)
      10 frames
    4. Hibernate
      SessionImpl.delete
      1. org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:248)
      2. org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:201)
      3. org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:109)
      4. org.hibernate.impl.SessionImpl.delete(SessionImpl.java:579)
      4 frames
    5. test.base
      TestBase.delete
      1. test.base.TestBase.delete(TestBase.java:109)
      1 frame