An error occurred while executing this code:
public Iterable<T> findAllByIds(List<Integer> ids) {
Path<Integer> idField = root.get("id");
Predicate in = idField.in(ids);
query.select(root);
query.where(in);
query.orderBy(builder.asc(idField));
List<T> result = entityManager.createQuery(query).getResultList();
return result;
}
In line 2 the following exception is thrown:
Caused by: java.lang.IllegalArgumentException: Unaware how to convert value [[100, 101] : java.util.Arrays$ArrayList] to requested type [java.lang.Integer]
Hibernate version 5.2.11.Final, Java 8.
Try this :-
public Iterable<T> findAllByIds(List<Integer> ids) {
Expression<Integer> exp = root.get("id");
Predicate in = exp.in(ids);
query.select(root);
query.where(in);
query.orderBy(builder.asc(root.get("id")));
List<T> result = entityManager.createQuery(query).getResultList();
return result;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.