Hibernate JPA and Spring javax.persistence.TransactionRequiredException: no transaction is in progress

后端 未结 13 2819
说谎
说谎 2020-12-05 17:52

When I call:

entityManager.flush()

I get the exception mentioned in the title.

I am using Hibernate JPA.

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 18:40

    I had this problem, just add @Transacctional annotation not only on the method, also in the class together with your @Service annotation.

    for example:

    @Service
    @Transactional
    public class MyService {
    
    }
    

提交回复
热议问题