简体   繁体   中英

How to ignore @Transactional in JdbcTemplate

I'd like to create a library (jar) and use JdbcTemplate in it to simplify working with Database. But that library will be used in other Spring applications. And by default @Transactional annonations in application will affect the methods in library (JdbcTemplate in library will be aware of that outer Transaction). So I need to create JdbcTemplate so that it will ignore outer transactions. Is that possible?

So Application transaction propagation level shouldn't effect your library transaction management, is this my understanding correct?

If Yes, you may have a look at Propagation.NOT_SUPPORTED , ref

I believe you are going to design interface in your library which will expose public methods used by application, what if all interface method annotated with @Transactional(propagation = Propagation.NOT_SUPPORTED) ? wouldn't it solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM