I have a main thread that spawns thread # 2, which uses the same hibernation session in the main thread. Theme # 2 just βpicks 1β every few minutes to maintain a db connection due to the long process from the main thread. As soon as the main thread is executed with processing, it causes a commit, but I get an error:
Caused by: org.hibernate.TransactionException: JDBC commit failed at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:161) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655) ... 5 more Caused by: java.sql.SQLException: Can't call commit when autocommit=true at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:930) at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1602) at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:170) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146) ... 6 more
In the main thread, it creates internal transactions that are completed successfully, it is just an external transaction when it commits an error that causes this error. I do not see what can be changed using autocommit boolean. Before I introduced the second thread to keep in touch, this error never occurred.
spring multithreading hibernate session
czer
source share