Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用EJB解决hibernate中的LockAcquisitionException_Java_Multithreading_Hibernate_Ejb - Fatal编程技术网

Java 用EJB解决hibernate中的LockAcquisitionException

Java 用EJB解决hibernate中的LockAcquisitionException,java,multithreading,hibernate,ejb,Java,Multithreading,Hibernate,Ejb,我在应用程序中使用EJB和hibernate。在某些场景中,我应该有一个本机SQL查询,比如更新MY_表SET VALUE=VALUE+1,其中MY_KEY=20;除了同一事务中的此查询之外,还有其他一些hibernate操作可用,但这些操作不在同一个表中。同一个查询将有机会在另一个事务中运行,这意味着一个单独的线程将尝试运行同一个更新查询以及其他一些hibernate操作。当单线程运行时,一切正常,但在多线程场景中,我得到以下异常 org.hibernate.exception.LockAcq

我在应用程序中使用EJB和hibernate。在某些场景中,我应该有一个本机SQL查询,比如更新MY_表SET VALUE=VALUE+1,其中MY_KEY=20;除了同一事务中的此查询之外,还有其他一些hibernate操作可用,但这些操作不在同一个表中。同一个查询将有机会在另一个事务中运行,这意味着一个单独的线程将尝试运行同一个更新查询以及其他一些hibernate操作。当单线程运行时,一切正常,但在多线程场景中,我得到以下异常

org.hibernate.exception.LockAcquisitionException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:105)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:198)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1191)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:357)
at x.y.z.myMethod(MyClass.java:154)

我无法将线程减少到1。我的READ_未提交隔离级别。为什么我会得到这个例外?线程竞赛中发生了什么?有解决办法吗?如何修复?

您好,我遇到了相同的异常,并且处于相同的场景中。你找到解决办法了吗。还有其他选择吗