1 16 package com.ibatis.db.sqlmap; 17 18 import com.ibatis.common.util.PaginatedList; 19 import com.ibatis.sqlmap.client.SqlMapClient; 20 21 import javax.sql.DataSource ; 22 import java.sql.SQLException ; 23 import java.util.List ; 24 import java.util.Map ; 25 26 public class SqlMap { 27 28 private SqlMapClient client; 29 30 public SqlMap(SqlMapClient client) { 31 this.client = client; 32 } 33 34 public MappedStatement getMappedStatement(String name) { 35 return new MappedStatement(client, name); 36 } 37 38 public void startTransaction() 39 throws SQLException { 40 client.startTransaction(); 41 } 42 43 public void commitTransaction() 44 throws SQLException { 45 client.commitTransaction(); 46 client.endTransaction(); 47 } 48 49 public void rollbackTransaction() 50 throws SQLException { 51 client.endTransaction(); 52 } 53 54 public int executeUpdate(String statementName, Object parameterObject) 55 throws SQLException { 56 return client.update(statementName, parameterObject); 57 } 58 59 public Object executeQueryForObject(String statementName, Object parameterObject) 60 throws SQLException { 61 return client.queryForObject(statementName, parameterObject); 62 } 63 64 public Object executeQueryForObject(String statementName, Object parameterObject, Object resultObject) 65 throws SQLException { 66 return client.queryForObject(statementName, parameterObject, resultObject); 67 } 68 69 public Map executeQueryForMap(String statementName, Object parameterObject, String keyProperty) 70 throws SQLException { 71 return client.queryForMap(statementName, parameterObject, keyProperty); 72 } 73 74 public Map executeQueryForMap(String statementName, Object parameterObject, String keyProperty, String valueProperty) 75 throws SQLException { 76 return client.queryForMap(statementName, parameterObject, keyProperty, valueProperty); 77 } 78 79 public List executeQueryForList(String statementName, Object parameterObject) 80 throws SQLException { 81 return client.queryForList(statementName, parameterObject); 82 } 83 84 public List executeQueryForList(String statementName, Object parameterObject, int skipResults, int maxResults) 85 throws SQLException { 86 return client.queryForList(statementName, parameterObject, skipResults, maxResults); 87 } 88 89 public PaginatedList executeQueryForPaginatedList(String statementName, Object parameterObject, int pageSize) 90 throws SQLException { 91 return client.queryForPaginatedList(statementName, parameterObject, pageSize); 92 } 93 94 public void executeQueryWithRowHandler(String statementName, Object parameterObject, RowHandler rowHandler) 95 throws SQLException { 96 client.queryWithRowHandler(statementName, parameterObject, new RowHandlerAdapter(rowHandler)); 97 } 98 99 public void startBatch() 100 throws SQLException { 101 client.startBatch(); 102 } 103 104 public void endBatch() 105 throws SQLException { 106 client.executeBatch(); 107 } 108 109 public DataSource getDataSource() { 110 return client.getDataSource(); 111 } 112 113 114 } 115 | Popular Tags |