[Spring Data JPA問題]Executing an update/delete query; nested exception is javax.persistence.Transacti

JPQL以下:java

@Modifying(clearAutomatically = true)
@Query("UPDATE SyncTestFromTKDO SET stuAns = '' where typeId = ?1")
public void updateStuAns(Integer typeid);

項目運行時報錯,提示:spring

Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException

緣由:

update、delete操做涉及到事務機制,須要進行設置ui

解決方法:

在調用這個方法的service類上加上註解@Transactional(import org.springframework.transaction.annotation.Transactional;)spa

相關文章
相關標籤/搜索