Class SplibJpaExceptionHandler

java.lang.Object
jp.ecuacion.splib.web.exceptionhandler.SplibExceptionHandler
jp.ecuacion.splib.web.jpa.exceptionhandler.SplibJpaExceptionHandler

public abstract class SplibJpaExceptionHandler extends SplibExceptionHandler
Provides JPA related exception handling in addition to the handling within SplibExceptionHandler.

Use this class when the app uses JPA.

  • Constructor Details

    • SplibJpaExceptionHandler

      public SplibJpaExceptionHandler()
  • Method Details

    • handleObjectOptimisticLockingFailureException

      @ExceptionHandler(org.springframework.orm.ObjectOptimisticLockingFailureException.class) public org.springframework.web.servlet.ModelAndView handleObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception
      Catches ObjectOptimisticLockingFailureException and treats the optimistic exclusive controls.

      Optimistic exclusive control causes an exception when a record is updated in the interval between pressing the button and actually updating the record (A).
      But usually optimistic exclusive control is also needed when a record is updated in the interval between displaying the screen and pressing the button (B), and in the interval between displaying the record in the list page and displaying the detail page by selecting the record in the list page (C).

      (A) is implemented by JPA, and(A) throws ObjectOptimisticLockingFailureException.
      (A) automatically works so app developer don't have to cares about it. On the other hand (B) and (C) is not implemented by JPA, so it's implemented in ecuacion-splib.
      But in ecuacion-splib (B) and (C) also throws ObjectOptimisticLockingFailureException for integrated handling.

      Throws:
      Exception
    • handlePessimisticLockingFailureException

      @ExceptionHandler(org.springframework.dao.PessimisticLockingFailureException.class) public org.springframework.web.servlet.ModelAndView handlePessimisticLockingFailureException(org.springframework.dao.PessimisticLockingFailureException exception, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails loginUser) throws Exception
      Catches PessimisticLockingFailureException.
      Parameters:
      exception - exception
      loginUser - loginUser
      Returns:
      ModelAndView
      Throws:
      Exception - Exception