在以下 JPA 查询中, :fcIds 命名参数需要是整数值列表:
@NamedQuery(name = "SortTypeNWD.findByFcIds", query = "SELECT s FROM SortTypeNWD s WHERE s.sortTypeNWDPK.fcId IN (:fcIds)")
从逻辑上讲,这就是调用命名查询时所做的事情:
Query findByDatesPlFcIds = em.createNamedQuery("SortTypeNWD.findByFcIds");
findByDatesPlFcIds.setParameter("fcIds", fcIds);
其中变量 fcIds 是一个包含整数的 ArrayList。
上面的所有代码都适用于 Hibernate,但不适用于 TopLink:
Caused by: java.lang.IllegalArgumentException: You have attempted to set a value of type class java.util.ArrayList for parameter fcIds with expected type of int from query string SELECT s FROM SortTypeNWD s WHERE s.sortTypeNWDPK.fcId IN (:fcIds).
是否有在 TopLink 中使用 List 作为命名参数的解决方法?可以强制命名参数的类型吗?