本文介绍了org.hibernate.ejb.criteria.path.Abs​​tractPathImpl.get上的NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很好:

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

但我更改为:

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

并引发异常:

  @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;
  }

推荐答案

检查此答案.

元模型和类之类的似乎应该位于同一包中

seems like metamodel and class should be at the same package

这篇关于org.hibernate.ejb.criteria.path.Abs​​tractPathImpl.get上的NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 20:47