Arnie Schwarzvogel
Arnie Schwarzvogel

Reputation: 1005

Spring Boot JPA: @Modifying @Query has no effect

I'm trying to increase performance by executing one request instead of updating each entity. The sql looks right and the call to this method is executed but I see no "update" executed in hibernate log.

@Modifying
@Query("UPDATE Order x SET x.reservedByClient = :value WHERE x.tourId = :id")
public void updateReservationStatus(@Param("value") Boolean value, @Param("id") Long id);

Any hints where to look ?

Upvotes: 1

Views: 1652

Answers (1)

Dimitar Spasovski
Dimitar Spasovski

Reputation: 2132

Modifiying queries should be wrapped in a transaction. Try adding @Transactional to the query.

@Modifying
@Query("UPDATE Order x SET x.reservedByClient = :value WHERE x.tourId = :id")
@Transactional
public void updateReservationStatus(@Param("value") Boolean value, @Param("id") Long id);

Upvotes: 2

Related Questions