1

I have two entities with Left Join . Following are the code

Ooline.java

@Entity
@IdClass(OolineId.class)
@Table(name="OOLINE")
@NamedQuery(name="Ooline.findAll", query="SELECT o FROM Ooline o")
public class Ooline implements Serializable {
    private static final long serialVersionUID = 1L; 

    @OneToMany(targetEntity=Oohead.class, fetch=FetchType.LAZY) 
    @JoinColumns({
        @JoinColumn(name="OBCONO", referencedColumnName="OACONO"),
        @JoinColumn(name="OBORNO", referencedColumnName="OAORNO")
    })
    private List<Oohead> ooheadList ;

    @Id
    @Column(name="OBCONO")
    private BigDecimal obcono;
    @Id
    @Column(name="OBORNO")
    private String oborno;
    @Id
    @Column(name="OBPONR")
    private BigDecimal obponr;
    @Id
    @Column(name="OBPOSX")
    private BigDecimal obposx;
    //getter+setter

}

Oohead.java

@Entity
@IdClass(OoheadId.class)
@Table(name="OOHEAD")
@NamedQuery(name="Oohead.findAll", query="SELECT o FROM Oohead o")
public class Oohead implements Serializable {
    private static final long serialVersionUID = 1L;

    @ManyToOne
    private Ooline ooline;
    @Id
    @Column(name="OACONO")
    private BigDecimal oacono;
    @Id
    @Column(name="OAORNO")
    private String oaorno;
    //getter+setter

}

And I was trying to execute JPQL query

@Repository
public interface OoheadRepository extends  JpaRepository<Oohead, String> 
{

    public static final String ORDER_HEAD_FOR_ITNO_CUNO = "SELECT o FROM Oohead o "
            + "left join o.Ooline u where u.obcono=o.oacono and u.obponr=o.oaponr and u.obcono=:cono "
            + "and u.obitno=:itno and o.oacuno=:cuno";

    @Query(ORDER_HEAD_FOR_ITNO_CUNO)
    public List<Oohead>  getOrderHeadForItnoCuno(@Param("cono") String cono,@Param("cuno") String cuno,@Param("itno") String itno);

}

But I am getting NullPointer exception

Caused by: java.lang.NullPointerException
    at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1460) ~[hibernate-core-4.3.9.Final.jar:4.3.9.Final]
    at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:864) ~[hibernate-core-4.3.9.Final.jar:4.3.9.Final]
    at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:779) ~[hibernate-core-4.3.9.Final.jar:4.3.9.Final]
    at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:728) ~[hibernate-core-4.3.9.Final.jar:4.3.9.Final]

Can Anyone help me this , its stoping my work . Any help will be appreciated .

2
  • have a look at rthis ... solve it your problem? stackoverflow.com/questions/28653337/… Commented Jun 27, 2015 at 11:12
  • i think , i have configured the same way it is mentioning in that question . Did u find any difference ? Commented Jun 27, 2015 at 13:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.