【发布时间】:2017-04-07 05:19:36
【问题描述】:
我正在使用服务和 dao 使用 Spring + JPA(使用休眠作为 JPA 提供者)。
我想在 service 和 dao 中注入 JPA EntityManager,服务管理事务,dao 管理对象持久性。
服务中的dao是@Autowired,EntityManager在Service和Dao中都注入了@Autowired。
这样我保证在 Service 和 dao 中都注入相同的EntityManager 吗?
【问题讨论】:
-
@shazin : 如何将 JPA EntityManager bean 配置为单例或原型?