TransactionRequiredException Executing an update/delete query

后端 未结 20 2166
没有蜡笔的小新
没有蜡笔的小新 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:40

    Using @Modifying and @Transaction fixed me

    1. @Modifying @Query(value="DELETE FROM lock WHERE user_id = ?1" ,nativeQuery=true) void deleteByUserId(Long userId);

    2. @Service @Transactional

提交回复
热议问题