title: How to check if saveAndFlush() successfully updated the entity parameters in the database while using JpaRespository?
body: <p>I am currently developing a small Spring Rest + Spring Data application and the requirement is to update address (String address) of an User if the user already exists in the database. Now once I retrieve the user entity from database, I am setting the address string in the entity and calling saveAndFlush() on the entity. Now, here is my confusion. Incase this update operation is not successful (due to any reason whatsoever), I want to raise my own custom exception.</p>
  
  <ul>
  <li><p>How do I check if the update operation was successful? I know saveAndFlush will return an updated entity, and I am using the entity to check if it is same as the entity retrieved from database earlier. But this is failing when I am providing same address for the update. Is there any other way to check?</p></li>
  <li><p>What exception could be thrown from saveAndFlush() in between the update operation? Any specific exception as getOne() throws EntityNotFound exception. Incase of exception, will it return any entity from database? </p></li>
  </ul>
  
  <p>Can anyone please help me with these doubts. I googled the but could not get ny satisfactory answers.  </p>