1 16 package com.ibatis.dao.engine.transaction.sqlmap; 17 18 import com.ibatis.dao.client.DaoException; 19 import com.ibatis.dao.engine.transaction.ConnectionDaoTransaction; 20 import com.ibatis.sqlmap.client.SqlMapClient; 21 22 import java.sql.Connection ; 23 import java.sql.SQLException ; 24 25 public class SqlMapDaoTransaction implements ConnectionDaoTransaction { 26 27 private SqlMapClient client; 28 29 public SqlMapDaoTransaction(SqlMapClient client) { 30 try { 31 client.startTransaction(); 32 this.client = client; 33 } catch (SQLException e) { 34 throw new DaoException("Error starting SQL Map transaction. Cause: " + e, e); 35 } 36 } 37 38 public void commit() { 39 try { 40 client.commitTransaction(); 41 client.endTransaction(); 42 } catch (SQLException e) { 43 throw new DaoException("Error committing SQL Map transaction. Cause: " + e, e); 44 } 45 } 46 47 public void rollback() { 48 try { 49 client.endTransaction(); 50 } catch (SQLException e) { 51 throw new DaoException("Error ending SQL Map transaction. Cause: " + e, e); 52 } 53 } 54 55 public SqlMapClient getSqlMap() { 56 return client; 57 } 58 59 public Connection getConnection() { 60 try { 61 return client.getCurrentConnection(); 62 } catch (SQLException e) { 63 throw new DaoException("Error getting connection from SQL Map Client. Cause: " + e, e); 64 } 65 } 66 67 } 68 | Popular Tags |