これは正常に機能します。
public Predicate toPredicate(Root<Campaign> root,
CriteriaQuery<?> query, CriteriaBuilder cb) {
return root.get("campState").get("statusId").in(campStatus);
}
しかし、私は:</p>に変更します
return root.get(Campaign_.campState).get(CampState_.campId).in(campStatus).
そしてそれは例外をスローします:</ p>
編集対象:org.hibernate.ejb.criteria.path.AbstractPathImpl.getのNullPointerException
@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;
}