2
をサポートしていない私は春のコアを使用していますが、私は次のコードorg.hibernate.TransactionException:ネストされたトランザクションは
@Transactional
public void updateExecutedStatus(Processing_File_data file,int status) throws SQLException {
System.out.println(this.getClass().getName()+"and method name is updateExecutedStatus start");
/*synchronized (this) {*/
//Session session=sessionFactory.openSession();
Session session=sessionFactory.getCurrentSession();
if(session==null||session.equals(null)){
session=sessionFactory.openSession();
}
try {
//Transaction tx1 = sessionFactory.getCurrentSession().beginTransaction();
Transaction tx1 = session.beginTransaction();
file.setStatus(status);
file.getLdb().setExecuted(status);
session.saveOrUpdate(file);
tx1.commit();
}
catch (Exception e) {
//log.error(e.getMessage());
e.printStackTrace();
}finally{
session.close();
}
/*}*/
System.out.println(this.getClass().getName()+"and method name is updateExecutedStatus end");
}
を使用していますintegration.Whileを休止状態私は次の例外を取得しています。
org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1435)
at pe.entel.dao.impl.MasDatabaseTransactImpl.updateExecutedStatus(MasDatabaseTransactImpl.java:147)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy23.updateExecutedStatus(Unknown Source)
at pe.entel.service.MassiveDatabaseServiceImpl.updateExecutedStatus(MasDatabaseServiceImpl.java:54)
at pe.entel.service.activation.masivas.servadd.core.SeMain.handler(SeMain.java:284)
at pe.entel.integrated.MasiRoot.getlists(MasiRoot.java:71)
at pe.entel.integrated.RecordsDistributedThread.run(RecordsDistributedThread.java:44)
私は上記の例外を取得し、スレッドを適用する際にコードがfine.But働いているスレッドずにしようとしていますtransactions.whileにスレッドを適用しています。
を削除する必要が別のトランザクションの間に、この問題を引き起こし、したがって開始され、その後にコミット。セッションはスレッドセーフではありません。 – Imran