SqlSession was not registered for synchronization because synchronization is not active

时间:2021-07-13
本文章向大家介绍SqlSession was not registered for synchronization because synchronization is not active,主要包括SqlSession was not registered for synchronization because synchronization is not active使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ed9f779] was not registered for synchronization because synchronization is not active
JDBC Connection [oracle.jdbc.driver.T4CConnection@54247b90] will not be managed by Spring
==> Preparing: INSERT INTO GATEWAY_LOG (  URL, RESULT, CREATED_TIME ) VALUES (  ?, ?, ? )
==> Parameters: 1626147605459(Long), https://test.qq.com.cn/inacd(String), {"code":0,"msg":"success","data":{"tList":[]}}(String), 2021-07-13 11:40:05.459(Timestamp)
<== Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ed9f779]

解决方式:

Service类上加上@Transactional

结果:

Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6a0c9067]
JDBC Connection [oracle.jdbc.driver.T4CConnection@4fe59894] will be managed by Spring
==> Preparing: insert into GATEWAY_LOG ( URL, RESULT, CREATED_TIME )values( ?, ?, ? )
==> Parameters: 1626147605459(Long), https://test.qq.com.cn/inacd(String), {"code":0,"msg":"success","data":{"tList":[]}}(String), 2021-07-13 11:40:05.459(Timestamp)
<== Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6a0c9067]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6a0c9067]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6a0c9067]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6a0c9067]



原文地址:https://www.cnblogs.com/qq714644953/p/15007250.html