【发布时间】:2016-08-21 02:51:39
【问题描述】:
// a is some String and bList is some list of type ArrayList
String findQuery = "SELECT T FROM " + MyClass.class.getName() + " T where a = :itemA and (b NOT IN (:bList))";
Query query = factory.getCurrentSession().createQuery(findQuery);
query.setParameter("itemA", a);
query.setParameter("bList", bList);
这是我正在执行的查询。它没有给我a = itemA and b is not in bList 的结果,而是给我a = itemA and b IS IN bList 的结果。
任何帮助将不胜感激。
【问题讨论】:
-
和 NOT (b IN (:bList)) 怎么样 ?
-
@Hogan 这不是 SQL,而是 HQL。创建查询(不是 NativeQuery)请参阅 stackoverflow.com/questions/6584898/…
-
请启用 SQL 日志并查看 Hibernate 生成的 SQL 请求。