Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果一个服务方法被标记为@Transactional嵌套传播,并且在其中有很多对其他@Transactional方法的调用,那么这些方法中的每一个都会使用自己的会话吗?对于一个方法调用,它应该代表与 db 的许多连接,不是吗?
@Transactional
看起来PROPAGATION_REQUIRED对您的目的来说是更好的选择。从它的javadoc:
PROPAGATION_REQUIRED
支持当前交易;如果不存在则创建一个新的。
请参阅此链接以获取更多详细信息