我需要验证binUse的属性首字母缩略词是否等于 BinUseAcronym.FPAN.toString()。我需要访问binUse.acronym
ProductBin
@Id
@Column(name = "ID")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "BIN_USE_ID", nullable = false)
private BinUse binUse;
BinUse
@Id
@Column
private Long id;
@Column
private String acronym;
My CriteriaQuery
ProductBin productBin = this.productBinRepository.findOne(new Specification<ProductBin>() {
@Override
public Predicate toPredicate(Root<ProductBin> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> listPredicate = new ArrayList<>();
listPredicate.add(cb.equal(root.get("start"), bin.getStart()));
listPredicate.add(cb.equal(root.get("end"), bin.getEnd()));
listPredicate.add(cb.equal(
root.get("BinUse_.acronym"), BinUseAcronym.FPAN.toString())
);
return cb.and(listPredicate.toArray(new Predicate[listPredicate.size()]));
}
});
我尝试在属性之前添加类名,但我一直收到异常:
InvalidDataAccessApiUsageException: Unable to locate Attribute with the the given name [BinUse_.acronym] on this ManagedType [com.edenred.commons.domain.ProductBin];
如何解决此错误?