1

I am using ReactiveCrudRepository with Spring web flux. Following query is not updating data in a Postgres database with r2dbc. I tried initially without @Modifying also. I used this annotation with reference of this link

@Modifying(flushAutomatically = true, clearAutomatically = true)
@Query("update company set deleted_at=current_timestamp, deleted_by=:deletedByUserId where id=:id")
Mono<Void> deleteById(Long id, Long deletedByUserId);
  • You are mixing JPA and Spring Data R2DBC annotations. Make sure to not use annotations for `javax.persistence` or `spring.data.jpa` with Spring Data R2dbc. I changed the tags so they match your question. You might want to review those. – Jens Schauder May 11 '20 at 05:38
  • @JensSchauder I tried it first before applying org.springframework.data.jpa.repository.Modifying (@Modifying) also. It wasn't working in my case. – Rhushikesh Chaudhari May 11 '20 at 11:28
  • There is a `@Modifying` for R2DBC. Use that. Also make sure to subscribe to the result. – Jens Schauder May 11 '20 at 14:10

1 Answers1

0

In case of webflux R2DBC, need to subscribe for the result. In your case make sure that result is handled in calling method. OR if you are calling from repository/service handle result or return from repository or service.

@DeleteMapping("/company")
public Mono<Void> deleteCompany(@PathVariable Integer companyId) {
     Mono<Void> result = repository. deleteById("deletedUserName", companyId);
     return result;
}
Ravi
  • 21
  • 4