org.hibernate.exception.SQLGrammarException:无法插入/选择ID进行批量删除

时间:2013-01-28 17:41:45

标签: hibernate jpa persistence bulk createquery

有以下java代码:

EntityTransaction myTransaction = myManager.getTransaction();
myTransaction.begin();
System.out.println(myManager.createQuery("delete from UserProfile where id > 16787504").executeUpdate());
myTransaction.commit();

运行后,会发生错误:

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk delete
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
    at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:60)

任何解决方案?

0 个答案:

没有答案