- DispatcherServlet에도 transation 세팅을 해줘야한다.
( Application Context의 설정이 DispatcherServlet의 설정과 공유되는것이 아니기때문에 각각 해줘야함. )
try catch 문으로 되어있으면 exception이 catch문에서 printStackTrace로 잡히기 때문에
public class UserMapperDaoImpl implements UserMapperDao{
private SqlSession sqlSession;
//gettter and setter for sqlSession
@Override
public void saveUser(User user) {
// TODO Auto-generated method stub
try {
UserMapperDao userMapper=sqlSession.getMapper(UserMapperDao.clas s);
userMapper.saveUser(user);
if(user.getName().equalsIgnoreCase("abc")){
throw new Exception("Simulate Error...");
}
}catch(Exception e){
e.printStackTrace();
}
}
}} catch(Exception e) {
e.printStackTrace();
thows new RuntimeException();
}
OR
Try catch 문을 없애고
public FourPillarsData getSajuFourPillars(FourPillarsInputData inputData) throws Exception{
이렇게 처리한다.
확인방법
트랜잭션 처리가 되었으면,
DEBUG: org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
DEBUG: org.mybatis.spring.SqlSessionUtils - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@304648]
처리가 되지 않았으면,
DEBUG: org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
DEBUG: org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1a51312] was not registered for synchronization because synchronization is not active
그리고 DefaultSqlSession 객체 주소가 각각의 프로세스 처리 Session 아이디와 같아야 된다
그래야만 롤백할때 한번에 날릴수있다.
참고
'Programming > springFramework' 카테고리의 다른 글
| [SpringFrameWork] 스프링 컨트롤러 map타입 으로 받기 (0) | 2016.05.17 |
|---|---|
| [Spring FrameWork] Maven install 시 ERROR (0) | 2016.05.11 |
| [SpringFramework] POST 전송시 ContentType (0) | 2016.03.04 |
| [Spring] PathVariable dot 오류 (0) | 2016.02.26 |
| [Spring] Ajax PUT 메서드 (0) | 2016.02.24 |