How to solve Hibernate's multi-threading problem?
淡淡烟草味
淡淡烟草味 2017-05-17 10:07:17
0
1
525

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.

淡淡烟草味
淡淡烟草味

reply all(1)
黄舟

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,

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!