Code example for JpaSystemException

Methods: getMostSpecificCause

0
     */ 
    @ExceptionHandler(JpaSystemException.class) 
    @ResponseBody 
    @ResponseStatus(CONFLICT) 
    public String handleJpaSystemException(JpaSystemException e) { 
        return e.getMostSpecificCause().getMessage(); 
    } 
 
    /** 
     * This is for custom controllers (i.e. not spring-data-rest) that do validation. 
     * @param ex The {@link org.springframework.data.rest.core.RepositoryConstraintViolationException} thrown by the controller. 
     * @return A map of fieldnames to FieldErrors 
     */ 
    @ResponseBody 
    @ResponseStatus(BAD_REQUEST) 
    @ExceptionHandler(RepositoryConstraintViolationException.class) 
    public RepositoryConstraintViolationExceptionMessage handleRepositoryConstraintViolationException(RepositoryConstraintViolationException ex) { 
        return new RepositoryConstraintViolationExceptionMessage(ex, messageSourceAccessor); 
    } 
} 
Contextual code suggestions in your IDE  Get Codota for Java