下面是带有spring事务的示例代码片段。我的问题: - 会使用相同的会话来获取第1行和第2行的实体吗?无交易提取数据
我的理解: - 我相信是的,它会通过Spring的事务来保证现在
@Transactional()
public void method1(
//fetch entity1 from dao with the help of entity manager//line 1
// fetch entity2 from dao with the help of entity manager//line 2
// now I fetch thru method entity.fetchLazyField()// line 3
)
如果我删除@Transactional()
。我相信只要entity1被提取,session就会被关闭,单独的session将被用于line2。对 ?
在3线(一旦@Transactional
被删除),我将能够获取数据或会话关闭异常应该抛出?
我不是粘贴大的XML配置和完整的DAO代码刚刚取得与实体管理器的etity。交易传播属性为Required
我的理解是你的陈述是正确的。 – Snickers3192