java.lang.NullPointerException

Hibernate JIRA | Regev Brody | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    When trying to define join columns on a @OneToMany association using @JoinFormula inside a @JoinColumnsOrFormulas list, A null pointer exception is thrown since the the bind fails to treat the Ejb3Column as a formula one, and tries to access the Column part of it. Stack trace: {noformat} 2015-07-07 01:54:12 ERROR HibernateUtil:22 - Initial SessionFactory creation failed. java.lang.NullPointerException at org.hibernate.cfg.Ejb3Column.isNullable(Ejb3Column.java:185) at org.hibernate.cfg.annotations.CollectionBinder.buildCollectionKey(CollectionBinder.java:1091) at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1524) at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:865) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:780) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:719) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54) at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1665) at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1640) at org.hibernate.boot.internal.MetadataBuildingProcess.build(MetadataBuildingProcess.java:282) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:396) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:82) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) {noformat} A test case: {code} table A int id (PK) table B int id (PK) table C int id (PK) int idB (FK to B.id) (PK) table D int idA (FK to A.id) (PK) int idC (FK to C.id) (PK) table E int idA (FK to A.id) (PK) int idB (FK to B.id) (PK) class E{ @OneToMany @JoinColumnsOrFormulas( { @JoinColumnOrFormula(formula = @JoinFormula(value = "idA", referencedColumnName = "idA")), @JoinColumnOrFormula(formula = @JoinFormula(value = "(SELECT __C.id FROM C AS __C WHERE __C.idB=idB)", referencedColumnName = "idC")) }) Set<D> ds = new HashSet<>(); } {code}

    Hibernate JIRA | 2 years ago | Regev Brody
    java.lang.NullPointerException
  2. 0

    When trying to define join columns on a @OneToMany association using @JoinFormula inside a @JoinColumnsOrFormulas list, A null pointer exception is thrown since the the bind fails to treat the Ejb3Column as a formula one, and tries to access the Column part of it. Stack trace: {noformat} 2015-07-07 01:54:12 ERROR HibernateUtil:22 - Initial SessionFactory creation failed. java.lang.NullPointerException at org.hibernate.cfg.Ejb3Column.isNullable(Ejb3Column.java:185) at org.hibernate.cfg.annotations.CollectionBinder.buildCollectionKey(CollectionBinder.java:1091) at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1524) at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:865) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:780) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:719) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54) at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1665) at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1640) at org.hibernate.boot.internal.MetadataBuildingProcess.build(MetadataBuildingProcess.java:282) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:396) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:82) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) {noformat} A test case: {code} table A int id (PK) table B int id (PK) table C int id (PK) int idB (FK to B.id) (PK) table D int idA (FK to A.id) (PK) int idC (FK to C.id) (PK) table E int idA (FK to A.id) (PK) int idB (FK to B.id) (PK) class E{ @OneToMany @JoinColumnsOrFormulas( { @JoinColumnOrFormula(formula = @JoinFormula(value = "idA", referencedColumnName = "idA")), @JoinColumnOrFormula(formula = @JoinFormula(value = "(SELECT __C.id FROM C AS __C WHERE __C.idB=idB)", referencedColumnName = "idC")) }) Set<D> ds = new HashSet<>(); } {code}

    Hibernate JIRA | 2 years ago | Regev Brody
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.cfg.Ejb3Column.isNullable()
    2. Hibernate
      CollectionSecondPass.doSecondPass
      1. org.hibernate.cfg.Ejb3Column.isNullable(Ejb3Column.java:185)
      2. org.hibernate.cfg.annotations.CollectionBinder.buildCollectionKey(CollectionBinder.java:1091)
      3. org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1524)
      4. org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:865)
      5. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:780)
      6. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:719)
      7. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54)
      7 frames
    3. org.hibernate.boot
      MetadataBuilderImpl.build
      1. org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1665)
      2. org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1640)
      3. org.hibernate.boot.internal.MetadataBuildingProcess.build(MetadataBuildingProcess.java:282)
      4. org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:396)
      5. org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:82)
      5 frames
    4. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
      2. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
      2 frames