@Modifying
@Query("update Member m set m.age = m.age + 1 where m.age >= :age")
int bulkAgePlus(@Param("age") int age);
@Modifying 어노테이션을 넣어야
.executeUpdate();
같은 메소드가 동작함
@Modifying 어노테이션에 들어가면 다음과 같은 설명을 볼 수 있음
데이터를 변경하는 쿼리임을 알려주는 어노테이션이라고 설명하고 있다.
Indicates a query method should be considered as modifying query as that changes the way it needs to be executed.
This annotation is only considered if used on query methods defined through a Query annotation.
It's not applied on custom implementation methods or queries derived from the method name as they already have control over the underlying data access APIs or specify if they are modifying by their name.
Queries that require a `@Modifying` annotation include INSERT, UPDATE, DELETE, and DDL statements.
spring 레퍼런스에서도 변경할때에는 @Modifying 붙이라고 써있다.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.modifying-queries