java问题与executeUpdate
我在Hibernate中遇到executeUpdate问题。 通过hibernate激发的查询如下
Update table set column1='abc',column2=:time,servertime=:servertime where service IN :arrservice
假设有4个服务需要更新 ‘abcd’、‘pqrs’、‘xyz’、‘def’
有时它会更新所有服务,有时会更新所有服务中的某些服务,有时不会更新任何服务
我既没有得到任何例外,也没有得到任何错误。 当我使用select对这些服务检查相同的查询时,我会得到它的记录,但同时更新对它们不起作用
String queryStm="Update table set column1='abc',column2=:time,servertime=:servertime where service IN :arrservice"
Query query = em.createNativeQuery(queryStm);
query.setParameter("arrservice", arrService);
query.setParameter("time", time);
query.setParameter("servertime", new Timestamp(new Date().getTime()));
LOG.debug("No updated" + query.executeUpdate());
如果有4个服务需要更新,上面的日志有时也会给出4、3、2和0
我不确定这里出了什么问题。为什么它不总是更新所有的4。 我在服务器上使用Postgres 10,以下是我在pom中包含的依赖项:-
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
任何帮助都是非常值得的
共 (0) 个答案