I am using spring jpa data with hibernate as a jpa continuity provider.
I use my own queries in my application. There are several update requests, and I would like to get the actual number of records updated when the update request was executed. Is there a way in spring jpa data for this?
I am currently following the approach below;
@Modifying @Query(value="update table x set x_provision = ?1 where x_id = ?2", nativeQuery=true) int updateProvision(Integer provision, Integer id);
@Transactional is added at the service level.
The problem is that when the table is updated, I get the score as 1. But there are cases when not a single row is updated. In this case, I also get the score as 1. But I would like to get the actual number of updated records, which is sometimes 0.
Can someone tell me if I am doing something wrong here?
source share