住所を更新したい。
@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")