001: /*
002: * Copyright 2002-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.orm.ibatis;
018:
019: import java.util.List;
020: import java.util.Map;
021:
022: import com.ibatis.common.util.PaginatedList;
023: import com.ibatis.sqlmap.client.event.RowHandler;
024:
025: import org.springframework.dao.DataAccessException;
026:
027: /**
028: * Interface that specifies a basic set of iBATIS SqlMapClient operations,
029: * implemented by {@link SqlMapClientTemplate}. Not often used, but a useful
030: * option to enhance testability, as it can easily be mocked or stubbed.
031: *
032: * <p>Defines SqlMapClientTemplate's convenience methods that mirror
033: * the iBATIS {@link com.ibatis.sqlmap.client.SqlMapExecutor}'s execution
034: * methods. Users are strongly encouraged to read the iBATIS javadocs
035: * for details on the semantics of those methods.
036: *
037: * @author Juergen Hoeller
038: * @since 24.02.2004
039: * @see SqlMapClientTemplate
040: * @see com.ibatis.sqlmap.client.SqlMapClient
041: * @see com.ibatis.sqlmap.client.SqlMapExecutor
042: */
043: public interface SqlMapClientOperations {
044:
045: /**
046: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForObject(String)
047: * @throws org.springframework.dao.DataAccessException in case of errors
048: */
049: Object queryForObject(String statementName)
050: throws DataAccessException;
051:
052: /**
053: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForObject(String, Object)
054: * @throws org.springframework.dao.DataAccessException in case of errors
055: */
056: Object queryForObject(String statementName, Object parameterObject)
057: throws DataAccessException;
058:
059: /**
060: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForObject(String, Object, Object)
061: * @throws org.springframework.dao.DataAccessException in case of errors
062: */
063: Object queryForObject(String statementName, Object parameterObject,
064: Object resultObject) throws DataAccessException;
065:
066: /**
067: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForList(String)
068: * @throws org.springframework.dao.DataAccessException in case of errors
069: */
070: List queryForList(String statementName) throws DataAccessException;
071:
072: /**
073: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForList(String, Object)
074: * @throws org.springframework.dao.DataAccessException in case of errors
075: */
076: List queryForList(String statementName, Object parameterObject)
077: throws DataAccessException;
078:
079: /**
080: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForList(String, int, int)
081: * @throws org.springframework.dao.DataAccessException in case of errors
082: */
083: List queryForList(String statementName, int skipResults,
084: int maxResults) throws DataAccessException;
085:
086: /**
087: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForList(String, Object, int, int)
088: * @throws org.springframework.dao.DataAccessException in case of errors
089: */
090: List queryForList(String statementName, Object parameterObject,
091: int skipResults, int maxResults) throws DataAccessException;
092:
093: /**
094: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryWithRowHandler(String, RowHandler)
095: * @throws org.springframework.dao.DataAccessException in case of errors
096: */
097: void queryWithRowHandler(String statementName, RowHandler rowHandler)
098: throws DataAccessException;
099:
100: /**
101: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryWithRowHandler(String, Object, RowHandler)
102: * @throws org.springframework.dao.DataAccessException in case of errors
103: */
104: void queryWithRowHandler(String statementName,
105: Object parameterObject, RowHandler rowHandler)
106: throws DataAccessException;
107:
108: /**
109: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForPaginatedList(String, int)
110: * @deprecated as of iBATIS 2.3.0
111: * @throws org.springframework.dao.DataAccessException in case of errors
112: */
113: PaginatedList queryForPaginatedList(String statementName,
114: int pageSize) throws DataAccessException;
115:
116: /**
117: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForPaginatedList(String, Object, int)
118: * @deprecated as of iBATIS 2.3.0
119: * @throws org.springframework.dao.DataAccessException in case of errors
120: */
121: PaginatedList queryForPaginatedList(String statementName,
122: Object parameterObject, int pageSize)
123: throws DataAccessException;
124:
125: /**
126: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForMap(String, Object, String)
127: * @throws org.springframework.dao.DataAccessException in case of errors
128: */
129: Map queryForMap(String statementName, Object parameterObject,
130: String keyProperty) throws DataAccessException;
131:
132: /**
133: * @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForMap(String, Object, String, String)
134: * @throws org.springframework.dao.DataAccessException in case of errors
135: */
136: Map queryForMap(String statementName, Object parameterObject,
137: String keyProperty, String valueProperty)
138: throws DataAccessException;
139:
140: /**
141: * @see com.ibatis.sqlmap.client.SqlMapExecutor#insert(String)
142: * @throws org.springframework.dao.DataAccessException in case of errors
143: */
144: Object insert(String statementName) throws DataAccessException;
145:
146: /**
147: * @see com.ibatis.sqlmap.client.SqlMapExecutor#insert(String, Object)
148: * @throws org.springframework.dao.DataAccessException in case of errors
149: */
150: Object insert(String statementName, Object parameterObject)
151: throws DataAccessException;
152:
153: /**
154: * @see com.ibatis.sqlmap.client.SqlMapExecutor#update(String)
155: * @throws org.springframework.dao.DataAccessException in case of errors
156: */
157: int update(String statementName) throws DataAccessException;
158:
159: /**
160: * @see com.ibatis.sqlmap.client.SqlMapExecutor#update(String, Object)
161: * @throws org.springframework.dao.DataAccessException in case of errors
162: */
163: int update(String statementName, Object parameterObject)
164: throws DataAccessException;
165:
166: /**
167: * Convenience method provided by Spring: execute an update operation
168: * with an automatic check that the update affected the given required
169: * number of rows.
170: * @param statementName the name of the mapped statement
171: * @param parameterObject the parameter object
172: * @param requiredRowsAffected the number of rows that the update is
173: * required to affect
174: * @throws org.springframework.dao.DataAccessException in case of errors
175: */
176: void update(String statementName, Object parameterObject,
177: int requiredRowsAffected) throws DataAccessException;
178:
179: /**
180: * @see com.ibatis.sqlmap.client.SqlMapExecutor#delete(String)
181: * @throws org.springframework.dao.DataAccessException in case of errors
182: */
183: int delete(String statementName) throws DataAccessException;
184:
185: /**
186: * @see com.ibatis.sqlmap.client.SqlMapExecutor#delete(String, Object)
187: * @throws org.springframework.dao.DataAccessException in case of errors
188: */
189: int delete(String statementName, Object parameterObject)
190: throws DataAccessException;
191:
192: /**
193: * Convenience method provided by Spring: execute a delete operation
194: * with an automatic check that the delete affected the given required
195: * number of rows.
196: * @param statementName the name of the mapped statement
197: * @param parameterObject the parameter object
198: * @param requiredRowsAffected the number of rows that the delete is
199: * required to affect
200: * @throws org.springframework.dao.DataAccessException in case of errors
201: */
202: void delete(String statementName, Object parameterObject,
203: int requiredRowsAffected) throws DataAccessException;
204:
205: }
|