0
我想更新地址。彈簧數據jpa查詢字符串錯誤
@Modifying
@Query("update UserInfo u set u.address = ?1 where u.username = ?2")
void setAddress(String address, String username);
但它不起作用。
org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is org.springframework.dao.InvalidDataAccessApiUsageException:
|Exception Description: No transaction is currently active; nested exception is
javax.persistence.TransactionRequiredException: |Exception Description: No transaction
is currently active
它說我的查詢字符串是未知源
哪個理由佔據這個例外?
如何更新更新查詢中的多個字段?
@Query("update UserInfo u set u.address = ?1, u.phoneNumber = ?2 where u.username = ?3")