java.lang.NullPointerException

Hibernate JIRA | Andrey Yakovlev | 2 years ago
  1. 0

    A problem occurrs with the following mapping: {code} @Entity public class Person { @Id @GeneratedValue private Integer id; @Audited private String name; @Audited @OneToMany(mappedBy = "person", cascade = CascadeType.ALL) @OrderColumn(name = "index") private List<Document> documents; // getters, setters } @Entity public class Document { @Id @GeneratedValue private Integer id; @Audited private String contents; @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @ManyToOne @JoinColumn(name = "person_id") private Person person; // getters, setters } {code} It seems that in this case Envers ignores OrderColumn annotation and creates document_AUD table without index column: {code:sql} create table Document ( id integer generated by default as identity (start with 1), contents varchar(255), person_id integer, index integer, primary key (id) ) create table Document_AUD ( id integer not null, REV integer not null, REVTYPE tinyint, contents varchar(255), person_id integer, primary key (id, REV) ) {code} If we add index column manually it will always stay empty. And then if we try to access documents in Project revision it fails with NPE: {noformat} java.lang.NullPointerException at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:91) at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:40) at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:71) at org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50) at org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.iterator(CollectionProxy.java:74) {noformat} I think it's defenitely a bug. What are possible work-arounds? I attached a simple project with hsqldb that reproduces this bug.

    Hibernate JIRA | 2 years ago | Andrey Yakovlev
    java.lang.NullPointerException
  2. 0

    A problem occurrs with the following mapping: {code} @Entity public class Person { @Id @GeneratedValue private Integer id; @Audited private String name; @Audited @OneToMany(mappedBy = "person", cascade = CascadeType.ALL) @OrderColumn(name = "index") private List<Document> documents; // getters, setters } @Entity public class Document { @Id @GeneratedValue private Integer id; @Audited private String contents; @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @ManyToOne @JoinColumn(name = "person_id") private Person person; // getters, setters } {code} It seems that in this case Envers ignores OrderColumn annotation and creates document_AUD table without index column: {code:sql} create table Document ( id integer generated by default as identity (start with 1), contents varchar(255), person_id integer, index integer, primary key (id) ) create table Document_AUD ( id integer not null, REV integer not null, REVTYPE tinyint, contents varchar(255), person_id integer, primary key (id, REV) ) {code} If we add index column manually it will always stay empty. And then if we try to access documents in Project revision it fails with NPE: {noformat} java.lang.NullPointerException at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:91) at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:40) at org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:71) at org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50) at org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.iterator(CollectionProxy.java:74) {noformat} I think it's defenitely a bug. What are possible work-arounds? I attached a simple project with hsqldb that reproduces this bug.

    Hibernate JIRA | 2 years ago | Andrey Yakovlev
    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.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection()
    2. org.hibernate.envers
      CollectionProxy.iterator
      1. org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:91)
      2. org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.ListCollectionInitializor.addToCollection(ListCollectionInitializor.java:40)
      3. org.hibernate.envers.internal.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:71)
      4. org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50)
      5. org.hibernate.envers.internal.entities.mapper.relation.lazy.proxy.CollectionProxy.iterator(CollectionProxy.java:74)
      5 frames