TransactionRequiredException Executing an update/delete query

后端 未结 20 2139
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 15:29

Hi I am using hibernate JPA with spring and mongodb and i am running my application on Glassfish-4.0.

My service class is :

@Component
public class T         


        
20条回答
  •  盖世英雄少女心
    2020-12-02 15:44

    I received this exception when trying to run a bulk UPDATE query in a non-JTA (i.e. resource-local) entity manager in Java SE. I had simply forgotten to wrap my JPQL code in

    em.getTransaction().begin();
    

    and

    em.getTransaction().commit();
    

提交回复
热议问题