title: How to get count of updated records in spring data jpa?
body: <p>I am using spring data jpa with hibernate as jpa persistence provider.</p>
  
  <p>I am using native queries in my application. There are some update queries and I would like to get the actual number of records updated when the update query gets executed. Is there a way in spring data jpa to do this?</p>
  
  <p>I am currently following the below approach;</p>
  
  <pre><code>@Modifying
  @Query(value="update table x set x_provision = ?1 where x_id = ?2", nativeQuery=true)
  int updateProvision(Integer provision, Integer id);
  </code></pre>
  
  <p>@Transactional is added on service layer.</p>
  
  <p>The problem here is that when the table gets updated I get the count as 1. But there are some cases where no rows are updated. In this case also I get the count as 1. But I would like to receive the actual number of records updated which sometimes is 0.</p>
  
  <p>Can someone let me know if I am doing something wrong here?</p>