8
以下異常拋出Spring Batch的應用:「執行更新/刪除查詢」 例外@NamedQuery做REMOVE
19:12:40,083 ERROR main AbstractStep:213 - Encountered an error executing the step
javax.persistence.TransactionRequiredException: Executing an update/delete query
代碼,其中使用的命名查詢
entityManagerFactory.createEntityManager()
.createNamedQuery("removeQuery").executeUpdate();
也試圖將此代碼包裝在開始和承諾方法實體事務對象和,沒有幫助:
EntityManager em = entityManagerFactory.createEntityManager();
EntityTransaction transaction = em.getTransaction();
transaction.begin();
entityManagerFactory.createEntityManager()
.createNamedQuery("removeQuery").executeUpdate();
transaction.commit();
em.close();
entityManagerFactory.close();
預先感謝您
又是什麼'removeQuery'樣子? – 2010-07-03 15:17:56