ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [database] exception: spring framework(dao) & hibernate
    on a stormy night 2021. 5. 28. 03:30

    [들어가며]

    하욤... 오늘도 hibernate, spring 문서를 헤집었다. exception을 모두 외운다는 것은 어찌 보면 필수일 수 있지만 너무나 많은 exception과 끝나지 않은 신규 exception으로 고생한 날 스스로 달래며 나와 같은 개발자를 위해 글을 남긴다.

     


     

     

    [spring framework(dao)]

    • org.springframework.dao.DataAccessException: ROOT exception. try~catch 사용하지 말 것.
      • NonTransientDataAccessException: 일시적인 예외가 아니다. (동일한 작업은 실패한다.)
        • BindMarkersFactoryResolver.NoBindMarkersFactoryException
          = Cannot resolve a BindMarkersFactory.
        • CleanupFailureDataAccessException
          = Couldn't cleanup after a data access operation.
        • ConnectionFactoryLookupFailureException
          = Indicating that the specified ConnectionFactory could not be obtained.
        • DataIntegrityViolationException
          = Results in violation of an integrity constraint.
        • DataRetrievalFailureException
          = Data could not be retrieved.
        • DataSourceLookupFailureException
          =  Indicating that the specified DataSource could not be obtained.
        • InvalidDataAccessApiUsageException
          = Incorrect usage of the API.
        • InvalidDataAccessResourceUsageException
          = Data access resource incorrectly.
        • NonTransientDataAccessResourceException
          = A resource fails completely and the failure is permanent.
        • PermissionDeniedDataAccessException
          = The underlying resource denied a permission to access a specific element.
        • UncategorizedDataAccessException
          = Something went wrong with the underlying resource.
      • RecoverableDataAccessException: 일시적인 예외이다.
      • ScriptException: SQL 처리와 관련된 예외이다.
        • CannotReadScriptException
          = SQL script cannot be read.
        • ScriptParseException
          = SQL script cannot be properly parsed.
        • ScriptStatementFailedException
          = SQL script failed when executing it against the target database.
        • UncategorizedScriptException
          = Something went wrong while processing an SQL script.
      • TransientDataAccessException: 일시적인 예외이다.
        • ConcurrencyFailureException
          = subclassed to indicate the type of failure: optimistic locking, failure to acquire lock, etc.
        • QueryTimeoutException
          = a query timeout. 
        • TransientDataAccessResourceException
          = Resource fails temporarily and the operation can be retried.

     

     


    [hibernate]

    • org.hibernate.HibernateException: ROOT exception.
      • JDBCException: JDBC 호출 중에 예외가 발생하다.
        • ConstraintViolationException
          = Indicating that the requested DML operation resulted in a violation.
        • DataException
          = Implementation of JDBCException indicating that evaluation of the valid SQL statement.
        • GenericJDBCException
          = Generic, non-specific JDBCException.
        • JDBCConnectionException
          = Implementation of JDBCException indicating problems with communicating.
        • LockAcquisitionException
          = Implementation of JDBCException indicating a problem acquiring lock on the database.
        • SQLGrammarException
          = Implementation of JDBCException indicating that the SQL sent to the database was invalid

     


     

     

    [마치며]

     

    exception(예외): 일반 규칙이나 통례에서 벋어 남.

     

    MkMk형이라고 묻는다면 대다수가 Mk.42 아이언맨을 떠올린다. 이것은 혈액형이다. 이론 상으로만 가능하다고 판명한 혈액형, 1970년 대에 일본에서의 2명이 끝인 혈액형이다. 우린 혈액형을 데이터베이스에 저장한다면 ENUM('A', 'B', 'AB', 'O')만을 떠올릴 것 같다. exception, 즉 예외란 우리의 상식을 뛰어넘는 모든 행위와 상황을 뜻한다.

     

    개발자는 자신의 산출물(baby)이 누군가(babysitter)의 의해 다뤄지는 모습을 예상할 수 없다. 더 나아가서 기상천외한 방법으로 우리의 산출물을 아프게 만들 수 있다. 우리의 산출물은 자신의 아픔을 Exception을 던짐으로써 표현한다. 그러므로 우린 예외에 대해서 더 신중하게 다가갈 필요가 있고 예외 처리는 필수이다. 아무리 몇십 번 다시 생각해봐도 예외 처리를 잘 한 사람이 일하기 좋은 동료였다. 다른 사람들에게 난 그런 사람이었을까? 사소한 예외 처리가 사람의 목숨을 살릴 수도 있고 너의 하루, 이틀을 벌어줄 수 있다. 또 다른 이야기이고 조만간 테스트에서도 다룰 내용이지만 과연 예외 처리가 필요 없을 정도로 good 케이스만을 작성한 테스트는 필요할까? 빠욤...

    댓글

Designed by Tistory.