Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.resthub.jpa;
import org.hibernate.ObjectNotFoundException;
import org.resthub.common.model.RestError;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityNotFoundException;
/**
* Spring MVC exception handler user to map JPA related exception to HTTP error codes.
* Spring MVC is an optional dependency, it will be used only if already imported by your application.
*/
@ControllerAdvice
public class JpaHandlerExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(value={
ObjectNotFoundException.class,
EntityNotFoundException.class,
EntityExistsException.class,
DataIntegrityViolationException.class
})
public ResponseEntity