• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / ibatis-2 / 730

28 Dec 2025 10:16PM UTC coverage: 65.615% (+0.5%) from 65.146%
730

push

github

web-flow
Update README.md

1602 of 2802 branches covered (57.17%)

5053 of 7701 relevant lines covered (65.61%)

0.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.82
/src/main/java/com/ibatis/sqlmap/engine/impl/SqlMapClientImpl.java
1
/*
2
 * Copyright 2004-2025 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
 *    https://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.sqlmap.engine.impl;
17

18
import com.ibatis.common.logging.Log;
19
import com.ibatis.common.logging.LogFactory;
20
import com.ibatis.common.util.PaginatedList;
21
import com.ibatis.sqlmap.client.SqlMapClient;
22
import com.ibatis.sqlmap.client.SqlMapException;
23
import com.ibatis.sqlmap.client.SqlMapSession;
24
import com.ibatis.sqlmap.client.event.RowHandler;
25
import com.ibatis.sqlmap.engine.execution.BatchException;
26
import com.ibatis.sqlmap.engine.execution.SqlExecutor;
27
import com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactory;
28
import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
29

30
import java.sql.Connection;
31
import java.sql.SQLException;
32
import java.util.List;
33
import java.util.Map;
34

35
import javax.sql.DataSource;
36

37
/**
38
 * Implementation of ExtendedSqlMapClient.
39
 */
40
public class SqlMapClientImpl implements SqlMapClient, ExtendedSqlMapClient {
41

42
  /** The Constant log. */
43
  private static final Log log = LogFactory.getLog(SqlMapClientImpl.class);
1✔
44

45
  /** Delegate for SQL execution. */
46
  public SqlMapExecutorDelegate delegate;
47

48
  /** The local sql map session. */
49
  protected ThreadLocal<SqlMapSessionImpl> localSqlMapSession = new ThreadLocal<>();
1✔
50

51
  /**
52
   * Constructor to supply a delegate.
53
   *
54
   * @param delegate
55
   *          - the delegate
56
   */
57
  public SqlMapClientImpl(SqlMapExecutorDelegate delegate) {
1✔
58
    this.delegate = delegate;
1✔
59
  }
1✔
60

61
  @Override
62
  public Object insert(String id, Object param) throws SQLException {
63
    return getLocalSqlMapSession().insert(id, param);
1✔
64
  }
65

66
  @Override
67
  public Object insert(String id) throws SQLException {
68
    return getLocalSqlMapSession().insert(id);
×
69
  }
70

71
  @Override
72
  public int update(String id, Object param) throws SQLException {
73
    return getLocalSqlMapSession().update(id, param);
1✔
74
  }
75

76
  @Override
77
  public int update(String id) throws SQLException {
78
    return getLocalSqlMapSession().update(id);
1✔
79
  }
80

81
  @Override
82
  public int delete(String id, Object param) throws SQLException {
83
    return getLocalSqlMapSession().delete(id, param);
×
84
  }
85

86
  @Override
87
  public int delete(String id) throws SQLException {
88
    return getLocalSqlMapSession().delete(id);
×
89
  }
90

91
  @Override
92
  public Object queryForObject(String id, Object paramObject) throws SQLException {
93
    return getLocalSqlMapSession().queryForObject(id, paramObject);
1✔
94
  }
95

96
  @Override
97
  public Object queryForObject(String id) throws SQLException {
98
    return getLocalSqlMapSession().queryForObject(id);
1✔
99
  }
100

101
  @Override
102
  public Object queryForObject(String id, Object paramObject, Object resultObject) throws SQLException {
103
    return getLocalSqlMapSession().queryForObject(id, paramObject, resultObject);
1✔
104
  }
105

106
  @Override
107
  public List queryForList(String id, Object paramObject) throws SQLException {
108
    return getLocalSqlMapSession().queryForList(id, paramObject);
1✔
109
  }
110

111
  @Override
112
  public List queryForList(String id) throws SQLException {
113
    return getLocalSqlMapSession().queryForList(id);
1✔
114
  }
115

116
  @Override
117
  public List queryForList(String id, Object paramObject, int skip, int max) throws SQLException {
118
    return getLocalSqlMapSession().queryForList(id, paramObject, skip, max);
1✔
119
  }
120

121
  @Override
122
  public List queryForList(String id, int skip, int max) throws SQLException {
123
    return getLocalSqlMapSession().queryForList(id, skip, max);
×
124
  }
125

126
  /**
127
   * @deprecated All paginated list features have been deprecated
128
   */
129
  @Override
130
  @Deprecated
131
  public PaginatedList queryForPaginatedList(String id, Object paramObject, int pageSize) throws SQLException {
132
    return getLocalSqlMapSession().queryForPaginatedList(id, paramObject, pageSize);
1✔
133
  }
134

135
  /**
136
   * @deprecated All paginated list features have been deprecated
137
   */
138
  @Override
139
  @Deprecated
140
  public PaginatedList queryForPaginatedList(String id, int pageSize) throws SQLException {
141
    return getLocalSqlMapSession().queryForPaginatedList(id, pageSize);
1✔
142
  }
143

144
  @Override
145
  public Map queryForMap(String id, Object paramObject, String keyProp) throws SQLException {
146
    return getLocalSqlMapSession().queryForMap(id, paramObject, keyProp);
1✔
147
  }
148

149
  @Override
150
  public Map queryForMap(String id, Object paramObject, String keyProp, String valueProp) throws SQLException {
151
    return getLocalSqlMapSession().queryForMap(id, paramObject, keyProp, valueProp);
1✔
152
  }
153

154
  @Override
155
  public void queryWithRowHandler(String id, Object paramObject, RowHandler rowHandler) throws SQLException {
156
    getLocalSqlMapSession().queryWithRowHandler(id, paramObject, rowHandler);
1✔
157
  }
1✔
158

159
  @Override
160
  public void queryWithRowHandler(String id, RowHandler rowHandler) throws SQLException {
161
    getLocalSqlMapSession().queryWithRowHandler(id, rowHandler);
1✔
162
  }
1✔
163

164
  @Override
165
  public void startTransaction() throws SQLException {
166
    getLocalSqlMapSession().startTransaction();
1✔
167
  }
1✔
168

169
  @Override
170
  public void startTransaction(int transactionIsolation) throws SQLException {
171
    getLocalSqlMapSession().startTransaction(transactionIsolation);
×
172
  }
×
173

174
  @Override
175
  public void commitTransaction() throws SQLException {
176
    getLocalSqlMapSession().commitTransaction();
1✔
177
  }
1✔
178

179
  @Override
180
  public void endTransaction() throws SQLException {
181
    try {
182
      getLocalSqlMapSession().endTransaction();
1✔
183
    } finally {
184
      getLocalSqlMapSession().close();
1✔
185
      localSqlMapSession.remove();
1✔
186
    }
187
  }
1✔
188

189
  @Override
190
  public void startBatch() throws SQLException {
191
    getLocalSqlMapSession().startBatch();
1✔
192
  }
1✔
193

194
  @Override
195
  public int executeBatch() throws SQLException {
196
    return getLocalSqlMapSession().executeBatch();
1✔
197
  }
198

199
  @Override
200
  public List executeBatchDetailed() throws SQLException, BatchException {
201
    return getLocalSqlMapSession().executeBatchDetailed();
1✔
202
  }
203

204
  @Override
205
  public void setUserConnection(Connection connection) throws SQLException {
206
    try {
207
      getLocalSqlMapSession().setUserConnection(connection);
1✔
208
    } finally {
209
      if (connection == null) {
1!
210
        getLocalSqlMapSession().close();
×
211
      }
212
    }
213
  }
1✔
214

215
  /**
216
   * Get user connection.
217
   *
218
   * @return Current connection
219
   *
220
   * @throws SQLException
221
   *           the SQL exception
222
   *
223
   * @deprecated Use getCurrentconnection() instead.
224
   */
225
  @Override
226
  @Deprecated
227
  public Connection getUserConnection() throws SQLException {
228
    return getCurrentConnection();
×
229
  }
230

231
  @Override
232
  public Connection getCurrentConnection() throws SQLException {
233
    return getLocalSqlMapSession().getCurrentConnection();
1✔
234
  }
235

236
  @Override
237
  public DataSource getDataSource() {
238
    return delegate.getDataSource();
1✔
239
  }
240

241
  @Override
242
  public MappedStatement getMappedStatement(String id) {
243
    return delegate.getMappedStatement(id);
1✔
244
  }
245

246
  @Override
247
  public boolean isLazyLoadingEnabled() {
248
    return delegate.isLazyLoadingEnabled();
1✔
249
  }
250

251
  @Override
252
  public boolean isEnhancementEnabled() {
253
    return delegate.isEnhancementEnabled();
1✔
254
  }
255

256
  @Override
257
  public SqlExecutor getSqlExecutor() {
258
    return delegate.getSqlExecutor();
1✔
259
  }
260

261
  @Override
262
  public SqlMapExecutorDelegate getDelegate() {
263
    return delegate;
1✔
264
  }
265

266
  @Override
267
  public SqlMapSession openSession() {
268
    SqlMapSessionImpl sqlMapSession = new SqlMapSessionImpl(this);
1✔
269
    sqlMapSession.open();
1✔
270
    return sqlMapSession;
1✔
271
  }
272

273
  @Override
274
  public SqlMapSession openSession(Connection conn) {
275
    try {
276
      SqlMapSessionImpl sqlMapSession = new SqlMapSessionImpl(this);
1✔
277
      sqlMapSession.open();
1✔
278
      sqlMapSession.setUserConnection(conn);
1✔
279
      return sqlMapSession;
1✔
280
    } catch (SQLException e) {
×
281
      throw new SqlMapException("Error setting user provided connection.  Cause: " + e, e);
×
282
    }
283
  }
284

285
  /**
286
   * GetSession.
287
   *
288
   * @deprecated Use openSession()
289
   */
290
  @Override
291
  @Deprecated
292
  public SqlMapSession getSession() {
293
    log.warn(
×
294
        "Use of a deprecated API detected.  SqlMapClient.getSession() is deprecated.  Use SqlMapClient.openSession() instead.");
295
    return openSession();
×
296
  }
297

298
  @Override
299
  public void flushDataCache() {
300
    delegate.flushDataCache();
1✔
301
  }
1✔
302

303
  @Override
304
  public void flushDataCache(String cacheId) {
305
    delegate.flushDataCache(cacheId);
×
306
  }
×
307

308
  /**
309
   * Gets the local sql map session.
310
   *
311
   * @return the local sql map session
312
   */
313
  protected SqlMapSessionImpl getLocalSqlMapSession() {
314
    SqlMapSessionImpl sqlMapSession = localSqlMapSession.get();
1✔
315
    if (sqlMapSession == null || sqlMapSession.isClosed()) {
1!
316
      sqlMapSession = new SqlMapSessionImpl(this);
1✔
317
      localSqlMapSession.set(sqlMapSession);
1✔
318
    }
319
    return sqlMapSession;
1✔
320
  }
321

322
  @Override
323
  public ResultObjectFactory getResultObjectFactory() {
324
    return delegate.getResultObjectFactory();
1✔
325
  }
326
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc