KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > orm > ibatis > SqlMapCallback


1 /*
2  * Copyright 2002-2005 the original author or authors.
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
17 package org.springframework.orm.ibatis;
18
19 import java.sql.Connection JavaDoc;
20 import java.sql.SQLException JavaDoc;
21
22 import com.ibatis.db.sqlmap.MappedStatement;
23
24 /**
25  * Callback interface for data access code that works on an iBATIS Database Layer
26  * MappedStatement. To be used with SqlMapTemplate's execute method, assumably
27  * often as anonymous classes within a method implementation.
28  *
29  * <p>NOTE: The SqlMap/MappedStatement API is the one to use with iBATIS SQL Maps 1.x.
30  * The SqlMapClient/SqlMapSession API is only available with SQL Maps 2.
31  *
32  * @author Juergen Hoeller
33  * @since 28.11.2003
34  * @see SqlMapTemplate#execute(String, SqlMapCallback)
35  */

36 public interface SqlMapCallback {
37
38     /**
39      * Gets called by <code>SqlMapTemplate.execute</code> with an active JDBC
40      * Connection. Does not need to care about the lifecycle of the Connection
41      * or handling transactions.
42      *
43      * <p>If called without a thread-bound JDBC transaction (initiated by
44      * DataSourceTransactionManager), the code will simply get executed on the
45      * underlying JDBC connection with its transactional semantics. If using
46      * a JTA-aware DataSource, the JDBC connection and thus the callback code
47      * will be transactional if a JTA transaction is active.
48      *
49      * <p>Allows for returning a result object created within the callback, i.e.
50      * a domain object or a collection of domain objects. Note that there's
51      * special support for single step actions: see SqlMapTemplate.
52      * A thrown RuntimeException is treated as application exception, it gets
53      * propagated to the caller of the template.
54      *
55      * @param stmt the iBATIS Database Layer mapped statement
56      * @param con the JDBC Connection to work on
57      * @return a result object, or null if none
58      * @throws SQLException if thrown by MappedStatement methods
59      * @see SqlMapTemplate#executeQueryForList
60      * @see SqlMapTemplate#executeQueryForMap
61      * @see SqlMapTemplate#executeUpdate
62      * @see org.springframework.jdbc.datasource.DataSourceTransactionManager
63      */

64     Object JavaDoc doInMappedStatement(MappedStatement stmt, Connection JavaDoc con) throws SQLException JavaDoc;
65
66 }
67
Popular Tags