如何将类型转换为“规范”“toPredicate”方法?
前任:
@Entity
public class Empresa{...}
@Entity
public class Cliente extends Empresa{
private Integer cod;
...
}
@Entity
public class Vinculo{
private Empresa emp1;
private Empresa emp2;
}
public static Specification<Vinculo> serieEq(final Integer cod) {
return new Specification<Vinculo>() {
@Override
public Predicate toPredicate(Root<Vinculo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
return cb.equal(root.join("emp2").get("cod"), cod);
};
}
请注意,“cod”仅存在于 Cliente 中。
非常感谢,