I have an searchValue, inputted by user, and I want to find all the customers that have similar name, email, username, phone,... etc. like it. I'm using the Specifications to create a spec then inject it into repository file This is the Entity
public class DealRequestEntity {
private long id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "customer_id", referencedColumnName = "id")
private CustomerEntity customer;
}
And the Specifications
public class DealRequestSpecifications {
public static Specification<DealRequestEntity> hasSearchValue(String searchValue) {
return new Specification<DealRequestEntity>() {
public Predicate toPredicate(Root<DealRequestEntity> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
return builder.like(builder.lower(root.get("customer").get("name")), searchValue.toLowerCase());
}
};
}
}
And the get("name") always warning error there. So what is the right keyword that I can research for this?
I tried to get("customer").get("name") but it didn't work