Spring @Transactional not creating required transaction

后端 未结 3 1369
悲&欢浪女
悲&欢浪女 2021-02-07 11:59

Ok, so I\'ve finally bowed to peer pressure and started using Spring in my web app :-)...

So I\'m trying to get the transaction handling stuff to work, and I just can\'t

3条回答
  •  不思量自难忘°
    2021-02-07 12:50

    The instance of entity manager obtained from EntityManagerFactory.createEntityManager() doesn't participate in Spring-managed transactions.

    The usual way to obtain an entity manager is to inject it using @PersistenceContext-annotated property:

    @PersistenceContext
    public void setEntityManager(EntityManager em) { ... }
    

提交回复
热议问题