It is fast, but entities already loaded keep their old values until you clear the context.
@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("update Order o set o.status = :to where o.status = :from")
int bulkTransition(@Param("from") Status from, @Param("to") Status to);
update orders set status=? where status=? -> 4213 rows in one statement
Without clearAutomatically, an Order already in the session
still reports the OLD status.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11