实体订单包含字段:
@ManyToOne(optional = false)
private AbstractRequester requester;
我想通过输入这个字段来获取数据。
我在文档中创建了规范,但是在
page = orderRepository.findAll(spec, pageable);
获取异常
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: could not resolve property: class of: ...order.Order
我的规格:
@Override
public Predicate toPredicate(Root<Order> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate megaPredicate = cb.conjunction();`
...
megaPredicate = cb.and(megaPredicate, cb.and(
cb.equal(root.get("requester").type(), cb.literal(PersonRequester.class))
...
return megaPredicate;
}