使用SpringData JPA進行修改字段操作時出現的2個錯誤

一、
問題:

 t_user is not mapped

解決:

@Query("update t_user u set u.username = ?1 where u.id = ?2")

改成

@Query("update User u set u.username = ?1 where u.id = ?2")

二、
問題:

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

解決:
加上@Transactional註釋

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章