I have a page that implements a function. Triggering this function will execute two java functions at the same time, thereby triggering two Hibernate operations. After executing this function, the system will issue this Exception from time to time:
org.hibernate.TransactionException: Transaction not successfully started
I personally think it is because the session was closed by the previous Hibernate operation, resulting in the transaction of the latter operation being unable to be executed.
After Baidu, I tried this method, but it didn’t seem to work:
<property name="hibernateProperties">
<props>
<prop key="hibernate.autoReconnect">true</prop>
</props>
</property>
So, let me ask an expert to give me some advice.
It depends on what your code is.
Is your trigger multi-threaded or just executing two different methods in the same thread?
For example, service.method1, service.method2, the aspect of the transaction is in the service layer , then these two method transactions are independent,