You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think after step 2, the datasource 2 SqlSession should not be stored in the thread.
Code
SqlSessionUtils#registerSessionHolder
private static void registerSessionHolder(SqlSessionFactory sessionFactory, ExecutorType executorType,
PersistenceExceptionTranslator exceptionTranslator, SqlSession session) {
SqlSessionHolder holder;
if (TransactionSynchronizationManager.isSynchronizationActive()) {
Environment environment = sessionFactory.getConfiguration().getEnvironment();
if (environment.getTransactionFactory() instanceof SpringManagedTransactionFactory) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registering transaction synchronization for SqlSession [" + session + "]");
}
holder = new SqlSessionHolder(session, executorType, exceptionTranslator);
// Key Point: If transaction synchronization is active for the current thread, sqlsession is binded to the thread. I think this logic is wrong.
TransactionSynchronizationManager.bindResource(sessionFactory, holder);
TransactionSynchronizationManager.registerSynchronization(new SqlSessionSynchronization(holder, sessionFactory));
holder.setSynchronizedWithTransaction(true);
holder.requested();
} else {
As I mentioned in the code, I think this logic is wrong. Binding sqlsession to the thread should have the condition as:
there is transaction that corresponds to the current sqlsession
in this thread;
Version
Spring 4.3.5 & mybatis-spring 1.3.1
So I think this is a bug in mybatis-spring and I don't know how to fix it.
The text was updated successfully, but these errors were encountered:
Secne
Detail
I think after step 2, the datasource 2 SqlSession should not be stored in the thread.
Code
SqlSessionUtils#registerSessionHolder
As I mentioned in the code, I think this logic is wrong. Binding sqlsession to the thread should have the condition as:
in this thread;
Version
Spring 4.3.5 & mybatis-spring 1.3.1
So I think this is a bug in mybatis-spring and I don't know how to fix it.
The text was updated successfully, but these errors were encountered: