java.lang.NullPointerException

Hibernate JIRA | Quentin Ambard | 5 years ago
  1. 0

    There is an error fetching a collection of a subitem. This affect empty collections : a proxy is intialized on the collection, even fetched. Accessing to this collection fire a new request. Here is a simple mode. Please see test case for complete implementation: @Entity @Table( name = "ITEM" ) public class Item { @Id @GeneratedValue private Long id; @OneToOne(cascade = { CascadeType.ALL }, optional = true, fetch = FetchType.LAZY, orphanRemoval = true) @JoinColumn(name = "SUB_ITEM_ID") private SubItem subItem ; ... } public class SubItem { @Id @GeneratedValue private Long id; @ElementCollection(targetClass = String.class, fetch = FetchType.LAZY) @CollectionTable(name = "PHONES") @Column(name = "PHONE", nullable = false) private List<String> phones ; ... } the following hql request "from Item i left join fetch i.subItem left join fetch i.subItem.phones" generates this sql request : select item0_.id as id2_0_, subitem1_.id as id1_1_, item0_.SUB_ITEM_ID as SUB2_2_0_, phones3_.SubItem_id as SubItem1_1_0__, phones3_.PHONE as PHONE0__, phones3_.SubItem_id as SubItem1_1_0__, phones3_.PHONE as PHONE0__ from ITEM item0_ left outer join SUB_ITEM subitem1_ on item0_.SUB_ITEM_ID=subitem1_.id left outer join SUB_ITEM subitem2_ on item0_.SUB_ITEM_ID=subitem2_.id left outer join PHONES phones3_ on subitem2_.id=phones3_.SubItem_id There is an extra left outerjoin. QueryClassLoader.initialize(SelectClause selectClause) can't find the collectionOwner for the PHONES collection : collectionFromElement.getOrigin()is about the second left outer join : "SUB_ITEM subitem2_ on item0_.SUB_ITEM_ID=subitem2_.id" and the fromElementList is based on the first outer join "subitem1_ on item0_.SUB_ITEM_ID=subitem1_.id". The following hql request doesn't work either : from Item i left join fetch i.subItem s left join fetch s.phones Request is correctly generated, but the left outer join collectionPersisters is null java.lang.NullPointerException at org.hibernate.loader.BasicLoader.isBag(BasicLoader.java:97) at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:76) at org.hibernate.loader.hql.QueryLoader.<init>(QueryLoader.java:120) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:204) ... see attached test case for full stack

    Hibernate JIRA | 5 years ago | Quentin Ambard
    java.lang.NullPointerException
  2. 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
  3. 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.loader.BasicLoader.isBag()
    2. Hibernate
      QueryTranslatorImpl.doCompile
      1. org.hibernate.loader.BasicLoader.isBag(BasicLoader.java:97)
      2. org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:76)
      3. org.hibernate.loader.hql.QueryLoader.<init>(QueryLoader.java:120)
      4. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:204)
      4 frames