KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002-2006 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.SQLException JavaDoc;
20
21 import com.ibatis.sqlmap.client.SqlMapExecutor;
22
23 /**
24  * Callback interface for data access code that works with the iBATIS
25  * {@link com.ibatis.sqlmap.client.SqlMapExecutor} interface. To be used
26  * with {@link SqlMapClientTemplate}'s <code>execute</code> method,
27  * assumably often as anonymous classes within a method implementation.
28  *
29  * @author Juergen Hoeller
30  * @since 24.02.2004
31  * @see SqlMapClientTemplate
32  * @see org.springframework.jdbc.datasource.DataSourceTransactionManager
33  */

34 public interface SqlMapClientCallback {
35
36     /**
37      * Gets called by <code>SqlMapClientTemplate.execute</code> with an active
38      * <code>SqlMapExecutor</code>. Does not need to care about activating
39      * or closing the <code>SqlMapExecutor</code>, or handling transactions.
40      *
41      * <p>If called without a thread-bound JDBC transaction (initiated by
42      * DataSourceTransactionManager), the code will simply get executed on the
43      * underlying JDBC connection with its transactional semantics. If using
44      * a JTA-aware DataSource, the JDBC connection and thus the callback code
45      * will be transactional if a JTA transaction is active.
46      *
47      * <p>Allows for returning a result object created within the callback,
48      * i.e. a domain object or a collection of domain objects.
49      * A thrown custom RuntimeException is treated as an application exception:
50      * It gets propagated to the caller of the template.
51      *
52      * @param executor an active iBATIS SqlMapSession, passed-in as
53      * SqlMapExecutor interface here to avoid manual lifecycle handling
54      * @return a result object, or <code>null</code> if none
55      * @throws SQLException if thrown by the iBATIS SQL Maps API
56      * @see SqlMapClientTemplate#execute
57      * @see SqlMapClientTemplate#executeWithListResult
58      * @see SqlMapClientTemplate#executeWithMapResult
59      */

60     Object JavaDoc doInSqlMapClient(SqlMapExecutor executor) throws SQLException JavaDoc;
61
62 }
63
Popular Tags