public void do_UPDATE(Set<Long> customerIdSet) {
final String query =
"UPDATE product_orders po " +
"INNER join customer c " +
"ON po.order_id = c.order_id " +
"SET po.updated_on = now() " +
"WHERE c.customer_id IN (:customerIdSet)";
List<Long> ids = new ArrayList<Long>(customerIdSet.size());
for(final Long id : customerIdSet) {
ids.add(id);
}
_sessionFactory
.getCurrentSession()
.createSQLQuery(query)
.setParameterList("customerIdSet", ids)
.executeUpdate();
}
我收到SQLGrammarException。这个查询实际上运行在一个真正的MySQL控制台中,但为什么Hibernate认为它是正确的语法?休眠,无法执行具有连接的本机SQL更新查询
'.createQuery(查询)'? http://stackoverflow.com/questions/8636806/difference-between-hibernate-createcriteria-createquery-createsqlquery-functio – Alex
这是一个用于创建HQL查询。 –
'.setParameter('呢?因为你的'customerIdSet'不是'List'型 – Alex