-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
I've met a problem when I hope my service method shouldn't be wrapped by a transaction.Because there's several http requests and the method took a long time to finish itself and then, many threads hold the jdbc connections too long that my connection pool is empty and many CannotGetJdbcConnectionException were be thrown. So I marked the method with @transactional(propagation = Propagation.NOT_SUPPORTED), but it dosn't work.
I checked the SqlSessionTemplate and found that it'll invoke SqlSessionUtils.registerSessionHolder method to bind the SqlSession to TransactionSynchronizationManager if the TransactionFactory is implemented by SpringManagedTransactionFactory. It only works well then my transaction propagation behavior is Propagation.REQUIRED I bet.
So I think we should reimplement the SqlSessionTemplate and writer a MybatisTransactionManager to take the place of SqlSessionSynchronization.
Or if there's a better choice for me?