- MyBatis
public void updateSample(testDto param) throws Exception { SqlSession tmpSession = sqlSessionFactory.openSession(); try{ // Delete all tmpSession.delete("deleteSample", param);
// Insert New Data tmpSession.insert("insertSample", param);
tmpSession.commit(); }catch(Exception e){ tmpSession.rollback(); logger.error("TestDao updateSample e : "+e.getMessage()); throw e; }finally{ if(tmpSession != null)tmpSession.close(); } } |
- iBatis
public void updateSample(testDto param) throws DataAccessException, Exception { SqlMapClient sqlMap = getSqlMapClient(); try{ sqlMap.startTransaction();
//Delete all sqlMap.delete("deleteSample");
// Insert New Data sqlMap.insert("insertSample", param);
sqlMap.commitTransaction(); }catch(DataAccessException e){ logger.error("TestDao updateSample DataAccessException e ==> "+e.getMessage()); throw e; }catch(Exception e){ logger.error("TestDao updateSample Exception e ==> "+e.getMessage()); throw e; }finally{ sqlMap.endTransaction(); // commitTransaction 이 되기 전에 endTransaction 을 만나면 자동 rollback 된다. } }
|
'IT > MyBatis' 카테고리의 다른 글
mybatis multiple datasource (0) | 2014.01.17 |
---|---|
ibatis like 검색 oracle, ms-sql, mysql (0) | 2013.12.24 |
DBCP와 iBatis를 통한 Connection Pooling (0) | 2013.12.24 |