JSON数组in查询,和equals查询
if (query.getLocationId() != null) {
predicates.add(cb.isTrue(cb.function(
"JSON_CONTAINS",
Boolean.class,
root.get("locationIds"), cb.literal("" + query.getLocationId()))));
}
if (query.getLocationIds() != null && !query.getLocationIds().isEmpty()) {
Expression<Integer> ja = cb.function("JSON_ARRAY", Integer.class, cb.literal(query.getLocationIds()));
predicates.add(cb.isTrue(
cb.function(
"JSON_CONTAINS",
Boolean.class,
root.get("locationIds"), ja
))
);
}