首页新闻找找看学习计划

springmvc+hibernate 3.6+jpa 并发时提交事务失败

0
[待解决问题]

当多用户同时提交操作,更新数据库时,会出现以下异常。不在并发时,可以提交事务成功。用的entitymanager.lock(entity, LockModeType.PESSIMISTIC_WRITE);engitymanager.lock(entity, LockModeType.PESSIMISTIC_WRITE);同时操作都会出现异常。怎么可以让事务强行提交或提交,不让事务回滚。谢谢解答
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:522)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
    .....
    .....
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2430)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2419)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: javax.persistence.RollbackException: Transaction marked as rollbackOnly
    at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:513)
    ... 59 more

pakl的主页 pakl | 初学一级 | 园豆:50
提问于:2017-03-30 19:55
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册