Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException at org.hibernate.ejb.criteria.path.AbstractPathImpl.get [duplicate]

This works fine:

 public Predicate toPredicate(Root<Campaign> root,
    CriteriaQuery<?> query, CriteriaBuilder cb) {
    return root.get("campState").get("statusId").in(campStatus);
}

but I change to :

 return  root.get(Campaign_.campState).get(CampState_.campId).in(campStatus).

And it throws exception:

edit for: NullPointerException at org.hibernate.ejb.criteria.path.AbstractPathImpl.get

  @StaticMetamodel(Campaign.class)
  public class Campaign_ {
  public static volatile SingularAttribute<Campaign, CampState> campState;
  public static volatile SingularAttribute<Campaign, Long> campId;
  }

  @StaticMetamodel(CampState.class)
  public class CampState_ {
  public static volatile SingularAttribute<CampState, String> statusId;
  }

  Campaign.class
  @ManyToOne(cascade = {CascadeType.REFRESH, CascadeType.MERGE})
  @JoinColumn(name = "camp_status")
  public CampState getCampState() {
    return campState;
  }

  public void setCampState(CampState campState) {
    this.campState = campState;
  }
like image 352
samung88 Avatar asked Jan 28 '13 03:01

samung88


1 Answers

check this answer.

seems like metamodel and class should be at the same package

like image 122
oak Avatar answered Oct 05 '22 22:10

oak