title: How to validate before saving and throw checked exception
body: <p>I have the following scenario: </p>
  
  <ul>
  <li>There's a user repository which can save/update a user</li>
  <li>I want to validate the user's firstname/lastname (perform some string operations) before saving/updating</li>
  <li>If the user's firstname/lastname is &lt; 2 character after having performed the operations, a checked custom <code>UnacceptableStringValueException</code> should be thrown</li>
  </ul>
  
  <p>Note that many services access the user repository, so it's cumbersome to implement new logic directly before saving.</p>
  
  <p>What I tried to do in order to perform the validation just before saving/updating without having to implement this for every save/update call explicitly, is to use a JPA listener. Using <code>@PrePersist</code> and <code>@PreUpdate</code> 
   I achieved the goal of performing the validation before each save/update.
  However there are two problems with this solution:</p>
  
  <ul>
  <li>The checked exception is not enforced on the methods which save/update a user and the exception gets automatically wrapped as a <code>RuntimeException</code> via the listener</li>
  <li>When trying to use AOP to catch said <code>RuntimeException</code> and unpack the original checked exception, I keep getting <code>org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only</code></li>
  </ul>
  
  <p>Note that a simple service layer performing the check before saving/updating the user won't solve my use case because there's a user role repository which could also save/update a user (<code>@ManyToOne(optional = false, cascade = CascadeType.PERSIST)</code>)</p>
  
  <p>What's a good way to solve the constraints described in the scenario on top?</p>