I need to validate if the attribute acronym of binUse is equal to BinUseAcronym.FPAN.toString(). I need access 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()]));
}
});
I try to add the class name before attribute but I keep receiving a exception:
InvalidDataAccessApiUsageException: Unable to locate Attribute with the the given name [BinUse_.acronym] on this ManagedType [com.edenred.commons.domain.ProductBin];
How can I resolve this error?