我要更新地址。
@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")