Obtaining EntityManager in Spring + Hibernate configuration

后端 未结 2 1404
误落风尘
误落风尘 2021-02-04 02:19

I have a Spring MVC 4.0 application, and I am learning JPA. I use Hibernate as the JPA implementation.

I can configure Hibernate as described in this tutorial. It works

相关标签:
2条回答
  • 2021-02-04 02:47

    It can be use with @Autowired as shown in https://stackoverflow.com/a/33742769/2028440

    @Autowired
    private EntityManager entityManager;
    
    0 讨论(0)
  • 2021-02-04 02:58

    For the @PersistenceContext EntityManager entityManager; approach, add tx:annotation-driven to your .xml configuration and mark your methods where you use entityManager as @Transactional.

    0 讨论(0)
提交回复
热议问题