the valid jpa update entity code gives the exception below in the case of wrong dependency( org.hibernate, hibernate-core, 4.2.0.CR1)
entityManager.getTransaction().begin();
CompactDisc compactDisc = entityManager.find(CompactDisc.class, 7777);
compactDisc.setTitle("ZZZZZZZ");
entityManager.getTransaction().commit();
entityManager.close();
Exception in thread "main" javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:92)
at com.conygre.training.entities.LifecycleTester.main(LifecycleTester.java:25)
Caused by: java.lang.NullPointerException
at org.hibernate.ejb.event.EJB3PostUpdateEventListener.handlePostUpdate(EJB3PostUpdateEventListener.java:71)
at org.hibernate.ejb.event.EJB3PostUpdateEventListener.onPostUpdate(EJB3PostUpdateEventListener.java:67)
at org.hibernate.action.internal.EntityUpdateAction.postUpdate(EntityUpdateAction.java:248)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:205)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:328)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1212)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:400)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)
As a resolution Change the version to to 4.1.9.Final or 3.6.10.Final
javax.persistence.RollbackException: Error while committing the transaction
最新推荐文章于 2022-08-04 15:26:56 发布