Spring + Hibernate + JTA 프로젝트에서 나는 예외 처리 작업을 시도하고있다.Spring Hibernate Exception Handling
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public HandsetManufacturer createHandsetManufacturer(
HandsetManufacturer handsetManufacturer)
throws HandsetManufacturerAlreadyExistsException{
HandsetManufacturer handsetManufacturer2=new HandsetManufacturer();
try {
handsetManufacturerDao.findByUniqueProperty(
HandsetManufacturer.class, NAME_PROPERTY,
handsetManufacturer.getName());
throw new HandsetManufacturerAlreadyExistsException();
} catch (BusinessObjectNotFoundException ignoreMe) {
}
//handsetManufacturer2= handsetManufacturerDao.create(handsetManufacturer);
try{
handsetManufacturer2= handsetManufacturerDao.create(handsetManufacturer);
}catch (JDBCException e) {
System.out.println("::HibernateException::"+e.getSQL());
System.out.println("::HibernateException::"+e.getErrorCode());
System.out.println("::HibernateException::"+e.getSQLState());
System.out.println("::HibernateException::"+e.getSQLException());
System.out.println("::HibernateException::"+e.getMessage());
System.out.println("::HibernateException::"+e.getCause());
throw new TechnicalException(e);
}
return handsetManufacturer2;
}
내가 (종속 실체는 여전히 org.springframework.orm.hibernate3.HibernateJdbcException 실패합니다 제거를 제시 할 때, 예를 들어) 기본 최대 절전/JDBC/DB 예외를 잡으려고 노력하고있어 다음 코드 몇 가지 작업을 수행하십시오. 그러나 catch 코드에 도달하지 않습니다.
하지만 "@Transactional (propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)"을 제거하면 내 방식에서 블록을 잡을 수 있습니다. 이것이 스프링이 관리하는 방식과 관련이 있다고 생각합니다. 그러나 JDBCException 동안 예외를 잡아낼 수 있는지, 그리고 @Transaction annotation을 사용하는 방법을 모르겠다.
도움이 되었습니까?