KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > db > sqlmap > SqlMap


1 /*
2  * Copyright 2004 Clinton Begin
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc;
22 import java.sql.SQLException JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
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 JavaDoc name) {
35     return new MappedStatement(client, name);
36   }
37
38   public void startTransaction()
39       throws SQLException JavaDoc {
40     client.startTransaction();
41   }
42
43   public void commitTransaction()
44       throws SQLException JavaDoc {
45     client.commitTransaction();
46     client.endTransaction();
47   }
48
49   public void rollbackTransaction()
50       throws SQLException JavaDoc {
51     client.endTransaction();
52   }
53
54   public int executeUpdate(String JavaDoc statementName, Object JavaDoc parameterObject)
55       throws SQLException JavaDoc {
56     return client.update(statementName, parameterObject);
57   }
58
59   public Object JavaDoc executeQueryForObject(String JavaDoc statementName, Object JavaDoc parameterObject)
60       throws SQLException JavaDoc {
61     return client.queryForObject(statementName, parameterObject);
62   }
63
64   public Object JavaDoc executeQueryForObject(String JavaDoc statementName, Object JavaDoc parameterObject, Object JavaDoc resultObject)
65       throws SQLException JavaDoc {
66     return client.queryForObject(statementName, parameterObject, resultObject);
67   }
68
69   public Map JavaDoc executeQueryForMap(String JavaDoc statementName, Object JavaDoc parameterObject, String JavaDoc keyProperty)
70       throws SQLException JavaDoc {
71     return client.queryForMap(statementName, parameterObject, keyProperty);
72   }
73
74   public Map JavaDoc executeQueryForMap(String JavaDoc statementName, Object JavaDoc parameterObject, String JavaDoc keyProperty, String JavaDoc valueProperty)
75       throws SQLException JavaDoc {
76     return client.queryForMap(statementName, parameterObject, keyProperty, valueProperty);
77   }
78
79   public List executeQueryForList(String JavaDoc statementName, Object JavaDoc parameterObject)
80       throws SQLException JavaDoc {
81     return client.queryForList(statementName, parameterObject);
82   }
83
84   public List executeQueryForList(String JavaDoc statementName, Object JavaDoc parameterObject, int skipResults, int maxResults)
85       throws SQLException JavaDoc {
86     return client.queryForList(statementName, parameterObject, skipResults, maxResults);
87   }
88
89   public PaginatedList executeQueryForPaginatedList(String JavaDoc statementName, Object JavaDoc parameterObject, int pageSize)
90       throws SQLException JavaDoc {
91     return client.queryForPaginatedList(statementName, parameterObject, pageSize);
92   }
93
94   public void executeQueryWithRowHandler(String JavaDoc statementName, Object JavaDoc parameterObject, RowHandler rowHandler)
95       throws SQLException JavaDoc {
96     client.queryWithRowHandler(statementName, parameterObject, new RowHandlerAdapter(rowHandler));
97   }
98
99   public void startBatch()
100       throws SQLException JavaDoc {
101     client.startBatch();
102   }
103
104   public void endBatch()
105       throws SQLException JavaDoc {
106     client.executeBatch();
107   }
108
109   public DataSource JavaDoc getDataSource() {
110     return client.getDataSource();
111   }
112
113
114 }
115
Popular Tags