规范:
public Predicate toPredicate(Root<Hotel> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Predicate predicate = root.get("starRating").in(s);
if (unrated) {
predicate = cb.or(predicate, cb.isNull(root.get("starRating")));
}
return predicate;
}
哪里 s
是一个 Set
.
sql日志: Hibernate: select hotel0_.hotel_id as hotel_id1_16_, hotel0_.star_rating as star_ra13_16_ where hotel0_.active=? and (hotel0_.star_rating in () or hotel0_.star_rating is null) order by lower(hotel0_.hotel_name) asc
错误: ERROR 6828 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: syntax error at or near ")"
例外情况: org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
我错过了什么?
1条答案
按热度按时间mo49yndu1#
您查询的问题如下:
hotel0_.star_rating in ()
. 在此点之前对集合s进行空检查: