• 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

87.85
/src/main/java/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.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.mapping.statement;
17

18
import com.ibatis.common.io.ReaderInputStream;
19
import com.ibatis.common.jdbc.exception.NestedSQLException;
20
import com.ibatis.sqlmap.client.SqlMapClient;
21
import com.ibatis.sqlmap.client.event.RowHandler;
22
import com.ibatis.sqlmap.engine.cache.CacheKey;
23
import com.ibatis.sqlmap.engine.execution.SqlExecutor;
24
import com.ibatis.sqlmap.engine.impl.SqlMapClientImpl;
25
import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
26
import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
27
import com.ibatis.sqlmap.engine.mapping.sql.Sql;
28
import com.ibatis.sqlmap.engine.scope.ErrorContext;
29
import com.ibatis.sqlmap.engine.scope.StatementScope;
30
import com.ibatis.sqlmap.engine.transaction.Transaction;
31
import com.ibatis.sqlmap.engine.transaction.TransactionException;
32
import com.ibatis.sqlmap.engine.type.DomTypeMarker;
33
import com.ibatis.sqlmap.engine.type.XmlTypeMarker;
34

35
import java.io.StringReader;
36
import java.sql.Connection;
37
import java.sql.SQLException;
38
import java.util.ArrayList;
39
import java.util.Arrays;
40
import java.util.List;
41

42
import javax.xml.XMLConstants;
43
import javax.xml.parsers.DocumentBuilder;
44
import javax.xml.parsers.DocumentBuilderFactory;
45

46
import org.w3c.dom.Document;
47

48
/**
49
 * The Class MappedStatement.
50
 */
51
public class MappedStatement {
1✔
52

53
  /** The id. */
54
  private String id;
55

56
  /** The result set type. */
57
  private Integer resultSetType;
58

59
  /** The fetch size. */
60
  private Integer fetchSize;
61

62
  /** The result map. */
63
  private ResultMap resultMap;
64

65
  /** The parameter map. */
66
  private ParameterMap parameterMap;
67

68
  /** The parameter class. */
69
  private Class parameterClass;
70

71
  /** The sql. */
72
  private Sql sql;
73

74
  /** The base cache key. */
75
  private int baseCacheKey;
76

77
  /** The sql map client. */
78
  private SqlMapClientImpl sqlMapClient;
79

80
  /** The timeout. */
81
  private Integer timeout;
82

83
  /** The additional result maps. */
84
  private ResultMap[] additionalResultMaps = {};
1✔
85

86
  /** The execute listeners. */
87
  private List executeListeners = new ArrayList<>();
1✔
88

89
  /** The resource. */
90
  private String resource;
91

92
  /**
93
   * Gets the statement type.
94
   *
95
   * @return the statement type
96
   */
97
  public StatementType getStatementType() {
98
    return StatementType.UNKNOWN;
×
99
  }
100

101
  /**
102
   * Execute update.
103
   *
104
   * @param statementScope
105
   *          the statement scope
106
   * @param trans
107
   *          the trans
108
   * @param parameterObject
109
   *          the parameter object
110
   *
111
   * @return the int
112
   *
113
   * @throws SQLException
114
   *           the SQL exception
115
   */
116
  public int executeUpdate(StatementScope statementScope, Transaction trans, Object parameterObject)
117
      throws SQLException {
118
    ErrorContext errorContext = statementScope.getErrorContext();
1✔
119
    errorContext.setActivity("preparing the mapped statement for execution");
1✔
120
    errorContext.setObjectId(this.getId());
1✔
121
    errorContext.setResource(this.getResource());
1✔
122

123
    statementScope.getSession().setCommitRequired(true);
1✔
124

125
    try {
126
      parameterObject = validateParameter(parameterObject);
1✔
127

128
      Sql sql = getSql();
1✔
129

130
      errorContext.setMoreInfo("Check the parameter map.");
1✔
131
      ParameterMap parameterMap = sql.getParameterMap(statementScope, parameterObject);
1✔
132

133
      errorContext.setMoreInfo("Check the result map.");
1✔
134
      ResultMap resultMap = sql.getResultMap(statementScope, parameterObject);
1✔
135

136
      statementScope.setResultMap(resultMap);
1✔
137
      statementScope.setParameterMap(parameterMap);
1✔
138

139
      errorContext.setMoreInfo("Check the parameter map.");
1✔
140
      Object[] parameters = parameterMap.getParameterObjectValues(statementScope, parameterObject);
1✔
141

142
      errorContext.setMoreInfo("Check the SQL statement.");
1✔
143
      String sqlString = sql.getSql(statementScope, parameterObject);
1✔
144

145
      errorContext.setActivity("executing mapped statement");
1✔
146
      errorContext.setMoreInfo("Check the statement or the result map.");
1✔
147
      int rows = sqlExecuteUpdate(statementScope, trans.getConnection(), sqlString, parameters);
1✔
148

149
      errorContext.setMoreInfo("Check the output parameters.");
1✔
150
      if (parameterObject != null) {
1✔
151
        postProcessParameterObject(statementScope, parameterObject, parameters);
1✔
152
      }
153

154
      errorContext.reset();
1✔
155
      sql.cleanup(statementScope);
1✔
156
      notifyListeners();
1✔
157
      return rows;
1✔
158
    } catch (SQLException e) {
1✔
159
      errorContext.setCause(e);
1✔
160
      throw new NestedSQLException(errorContext.toString(), e.getSQLState(), e.getErrorCode(), e);
1✔
161
    } catch (Exception e) {
1✔
162
      errorContext.setCause(e);
1✔
163
      throw new NestedSQLException(errorContext.toString(), e);
1✔
164
    }
165
  }
166

167
  /**
168
   * Execute query for object.
169
   *
170
   * @param statementScope
171
   *          the statement scope
172
   * @param trans
173
   *          the trans
174
   * @param parameterObject
175
   *          the parameter object
176
   * @param resultObject
177
   *          the result object
178
   *
179
   * @return the object
180
   *
181
   * @throws SQLException
182
   *           the SQL exception
183
   */
184
  public Object executeQueryForObject(StatementScope statementScope, Transaction trans, Object parameterObject,
185
      Object resultObject) throws SQLException {
186
    try {
187
      Object object = null;
1✔
188

189
      DefaultRowHandler rowHandler = new DefaultRowHandler();
1✔
190
      executeQueryWithCallback(statementScope, trans.getConnection(), parameterObject, resultObject, rowHandler,
1✔
191
          SqlExecutor.NO_SKIPPED_RESULTS, SqlExecutor.NO_MAXIMUM_RESULTS);
192
      List list = rowHandler.getList();
1✔
193

194
      if (list.size() > 1) {
1!
195
        throw new SQLException("Error: executeQueryForObject returned too many results.");
×
196
      }
197
      if (!list.isEmpty()) {
1✔
198
        object = list.get(0);
1✔
199
      }
200

201
      return object;
1✔
202
    } catch (TransactionException e) {
×
203
      throw new NestedSQLException("Error getting Connection from Transaction.  Cause: " + e, e);
×
204
    }
205
  }
206

207
  /**
208
   * Execute query for list.
209
   *
210
   * @param statementScope
211
   *          the statement scope
212
   * @param trans
213
   *          the trans
214
   * @param parameterObject
215
   *          the parameter object
216
   * @param skipResults
217
   *          the skip results
218
   * @param maxResults
219
   *          the max results
220
   *
221
   * @return the list
222
   *
223
   * @throws SQLException
224
   *           the SQL exception
225
   */
226
  public List executeQueryForList(StatementScope statementScope, Transaction trans, Object parameterObject,
227
      int skipResults, int maxResults) throws SQLException {
228
    try {
229
      DefaultRowHandler rowHandler = new DefaultRowHandler();
1✔
230
      executeQueryWithCallback(statementScope, trans.getConnection(), parameterObject, null, rowHandler, skipResults,
1✔
231
          maxResults);
232
      return rowHandler.getList();
1✔
233
    } catch (TransactionException e) {
×
234
      throw new NestedSQLException("Error getting Connection from Transaction.  Cause: " + e, e);
×
235
    }
236
  }
237

238
  /**
239
   * Execute query with row handler.
240
   *
241
   * @param statementScope
242
   *          the statement scope
243
   * @param trans
244
   *          the trans
245
   * @param parameterObject
246
   *          the parameter object
247
   * @param rowHandler
248
   *          the row handler
249
   *
250
   * @throws SQLException
251
   *           the SQL exception
252
   */
253
  public void executeQueryWithRowHandler(StatementScope statementScope, Transaction trans, Object parameterObject,
254
      RowHandler rowHandler) throws SQLException {
255
    try {
256
      executeQueryWithCallback(statementScope, trans.getConnection(), parameterObject, null, rowHandler,
1✔
257
          SqlExecutor.NO_SKIPPED_RESULTS, SqlExecutor.NO_MAXIMUM_RESULTS);
258
    } catch (TransactionException e) {
×
259
      throw new NestedSQLException("Error getting Connection from Transaction.  Cause: " + e, e);
×
260
    }
1✔
261
  }
1✔
262

263
  //
264
  // PROTECTED METHODS
265
  //
266

267
  /**
268
   * Execute query with callback.
269
   *
270
   * @param statementScope
271
   *          the statement scope
272
   * @param conn
273
   *          the conn
274
   * @param parameterObject
275
   *          the parameter object
276
   * @param resultObject
277
   *          the result object
278
   * @param rowHandler
279
   *          the row handler
280
   * @param skipResults
281
   *          the skip results
282
   * @param maxResults
283
   *          the max results
284
   *
285
   * @throws SQLException
286
   *           the SQL exception
287
   */
288
  protected void executeQueryWithCallback(StatementScope statementScope, Connection conn, Object parameterObject,
289
      Object resultObject, RowHandler rowHandler, int skipResults, int maxResults) throws SQLException {
290
    ErrorContext errorContext = statementScope.getErrorContext();
1✔
291
    errorContext.setActivity("preparing the mapped statement for execution");
1✔
292
    errorContext.setObjectId(this.getId());
1✔
293
    errorContext.setResource(this.getResource());
1✔
294

295
    try {
296
      parameterObject = validateParameter(parameterObject);
1✔
297

298
      Sql sql = getSql();
1✔
299

300
      errorContext.setMoreInfo("Check the parameter map.");
1✔
301
      ParameterMap parameterMap = sql.getParameterMap(statementScope, parameterObject);
1✔
302

303
      errorContext.setMoreInfo("Check the result map.");
1✔
304
      ResultMap resultMap = sql.getResultMap(statementScope, parameterObject);
1✔
305

306
      statementScope.setResultMap(resultMap);
1✔
307
      statementScope.setParameterMap(parameterMap);
1✔
308

309
      errorContext.setMoreInfo("Check the parameter map.");
1✔
310
      Object[] parameters = parameterMap.getParameterObjectValues(statementScope, parameterObject);
1✔
311

312
      errorContext.setMoreInfo("Check the SQL statement.");
1✔
313
      String sqlString = sql.getSql(statementScope, parameterObject);
1✔
314

315
      errorContext.setActivity("executing mapped statement");
1✔
316
      errorContext.setMoreInfo("Check the SQL statement or the result map.");
1✔
317
      RowHandlerCallback callback = new RowHandlerCallback(resultMap, resultObject, rowHandler);
1✔
318
      sqlExecuteQuery(statementScope, conn, sqlString, parameters, skipResults, maxResults, callback);
1✔
319

320
      errorContext.setMoreInfo("Check the output parameters.");
1✔
321
      if (parameterObject != null) {
1✔
322
        postProcessParameterObject(statementScope, parameterObject, parameters);
1✔
323
      }
324

325
      errorContext.reset();
1✔
326
      sql.cleanup(statementScope);
1✔
327
      notifyListeners();
1✔
328
    } catch (SQLException e) {
1✔
329
      errorContext.setCause(e);
1✔
330
      throw new NestedSQLException(errorContext.toString(), e.getSQLState(), e.getErrorCode(), e);
1✔
331
    } catch (Exception e) {
×
332
      errorContext.setCause(e);
×
333
      throw new NestedSQLException(errorContext.toString(), e);
×
334
    }
1✔
335
  }
1✔
336

337
  /**
338
   * Post process parameter object.
339
   *
340
   * @param statementScope
341
   *          the statement scope
342
   * @param parameterObject
343
   *          the parameter object
344
   * @param parameters
345
   *          the parameters
346
   */
347
  protected void postProcessParameterObject(StatementScope statementScope, Object parameterObject,
348
      Object[] parameters) {
349
  }
1✔
350

351
  /**
352
   * Sql execute update.
353
   *
354
   * @param statementScope
355
   *          the statement scope
356
   * @param conn
357
   *          the conn
358
   * @param sqlString
359
   *          the sql string
360
   * @param parameters
361
   *          the parameters
362
   *
363
   * @return the int
364
   *
365
   * @throws SQLException
366
   *           the SQL exception
367
   */
368
  protected int sqlExecuteUpdate(StatementScope statementScope, Connection conn, String sqlString, Object[] parameters)
369
      throws SQLException {
370
    if (statementScope.getSession().isInBatch()) {
1✔
371
      getSqlExecutor().addBatch(statementScope, conn, sqlString, parameters);
1✔
372
      return 0;
1✔
373
    }
374
    return getSqlExecutor().executeUpdate(statementScope, conn, sqlString, parameters);
1✔
375
  }
376

377
  /**
378
   * Sql execute query.
379
   *
380
   * @param statementScope
381
   *          the statement scope
382
   * @param conn
383
   *          the conn
384
   * @param sqlString
385
   *          the sql string
386
   * @param parameters
387
   *          the parameters
388
   * @param skipResults
389
   *          the skip results
390
   * @param maxResults
391
   *          the max results
392
   * @param callback
393
   *          the callback
394
   *
395
   * @throws SQLException
396
   *           the SQL exception
397
   */
398
  protected void sqlExecuteQuery(StatementScope statementScope, Connection conn, String sqlString, Object[] parameters,
399
      int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
400
    getSqlExecutor().executeQuery(statementScope, conn, sqlString, parameters, skipResults, maxResults, callback);
1✔
401
  }
1✔
402

403
  /**
404
   * Validate parameter.
405
   *
406
   * @param param
407
   *          the param
408
   *
409
   * @return the object
410
   *
411
   * @throws SQLException
412
   *           the SQL exception
413
   */
414
  protected Object validateParameter(Object param) throws SQLException {
415
    Object newParam = param;
1✔
416
    Class parameterClass = getParameterClass();
1✔
417
    if (newParam != null && parameterClass != null) {
1✔
418
      if (DomTypeMarker.class.isAssignableFrom(parameterClass)) {
1✔
419
        if (XmlTypeMarker.class.isAssignableFrom(parameterClass)) {
1✔
420
          if (!(newParam instanceof String) && !(newParam instanceof Document)) {
1!
421
            throw new SQLException("Invalid parameter object type.  Expected '" + String.class.getName() + "' or '"
×
422
                + Document.class.getName() + "' but found '" + newParam.getClass().getName() + "'.");
×
423
          }
424
          if (!(newParam instanceof Document)) {
1✔
425
            newParam = stringToDocument((String) newParam);
1✔
426
          }
427
        } else {
428
          if (!Document.class.isAssignableFrom(newParam.getClass())) {
1!
429
            throw new SQLException("Invalid parameter object type.  Expected '" + Document.class.getName()
×
430
                + "' but found '" + newParam.getClass().getName() + "'.");
×
431
          }
432
        }
433
      } else if (!parameterClass.isAssignableFrom(newParam.getClass())) {
1✔
434
        throw new SQLException("Invalid parameter object type.  Expected '" + parameterClass.getName() + "' but found '"
1✔
435
            + newParam.getClass().getName() + "'.");
1✔
436
      }
437
    }
438
    return newParam;
1✔
439
  }
440

441
  /**
442
   * String to document.
443
   *
444
   * @param s
445
   *          the s
446
   *
447
   * @return the document
448
   */
449
  private Document stringToDocument(String s) {
450
    try {
451
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
1✔
452
      documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
1✔
453
      documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
1✔
454
      documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
1✔
455
      DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
1✔
456
      return documentBuilder.parse(new ReaderInputStream(new StringReader(s)));
1✔
457
    } catch (Exception e) {
×
458
      throw new RuntimeException("Error occurred.  Cause: " + e, e);
×
459
    }
460
  }
461

462
  /**
463
   * Gets the id.
464
   *
465
   * @return the id
466
   */
467
  public String getId() {
468
    return id;
1✔
469
  }
470

471
  /**
472
   * Gets the result set type.
473
   *
474
   * @return the result set type
475
   */
476
  public Integer getResultSetType() {
477
    return resultSetType;
1✔
478
  }
479

480
  /**
481
   * Sets the result set type.
482
   *
483
   * @param resultSetType
484
   *          the new result set type
485
   */
486
  public void setResultSetType(Integer resultSetType) {
487
    this.resultSetType = resultSetType;
×
488
  }
×
489

490
  /**
491
   * Gets the fetch size.
492
   *
493
   * @return the fetch size
494
   */
495
  public Integer getFetchSize() {
496
    return fetchSize;
1✔
497
  }
498

499
  /**
500
   * Sets the fetch size.
501
   *
502
   * @param fetchSize
503
   *          the new fetch size
504
   */
505
  public void setFetchSize(Integer fetchSize) {
506
    this.fetchSize = fetchSize;
×
507
  }
×
508

509
  /**
510
   * Sets the id.
511
   *
512
   * @param id
513
   *          the new id
514
   */
515
  public void setId(String id) {
516
    this.id = id;
1✔
517
  }
1✔
518

519
  /**
520
   * Gets the sql.
521
   *
522
   * @return the sql
523
   */
524
  public Sql getSql() {
525
    return sql;
1✔
526
  }
527

528
  /**
529
   * Sets the sql.
530
   *
531
   * @param sql
532
   *          the new sql
533
   */
534
  public void setSql(Sql sql) {
535
    this.sql = sql;
1✔
536
  }
1✔
537

538
  /**
539
   * Gets the result map.
540
   *
541
   * @return the result map
542
   */
543
  public ResultMap getResultMap() {
544
    return resultMap;
1✔
545
  }
546

547
  /**
548
   * Sets the result map.
549
   *
550
   * @param resultMap
551
   *          the new result map
552
   */
553
  public void setResultMap(ResultMap resultMap) {
554
    this.resultMap = resultMap;
1✔
555
  }
1✔
556

557
  /**
558
   * Gets the parameter map.
559
   *
560
   * @return the parameter map
561
   */
562
  public ParameterMap getParameterMap() {
563
    return parameterMap;
1✔
564
  }
565

566
  /**
567
   * Sets the parameter map.
568
   *
569
   * @param parameterMap
570
   *          the new parameter map
571
   */
572
  public void setParameterMap(ParameterMap parameterMap) {
573
    this.parameterMap = parameterMap;
1✔
574
  }
1✔
575

576
  /**
577
   * Gets the parameter class.
578
   *
579
   * @return the parameter class
580
   */
581
  public Class getParameterClass() {
582
    return parameterClass;
1✔
583
  }
584

585
  /**
586
   * Sets the parameter class.
587
   *
588
   * @param parameterClass
589
   *          the new parameter class
590
   */
591
  public void setParameterClass(Class parameterClass) {
592
    this.parameterClass = parameterClass;
1✔
593
  }
1✔
594

595
  /**
596
   * Gets the resource.
597
   *
598
   * @return the resource
599
   */
600
  public String getResource() {
601
    return resource;
1✔
602
  }
603

604
  /**
605
   * Sets the resource.
606
   *
607
   * @param resource
608
   *          the new resource
609
   */
610
  public void setResource(String resource) {
611
    this.resource = resource;
1✔
612
  }
1✔
613

614
  /**
615
   * Gets the cache key.
616
   *
617
   * @param statementScope
618
   *          the statement scope
619
   * @param parameterObject
620
   *          the parameter object
621
   *
622
   * @return the cache key
623
   */
624
  public CacheKey getCacheKey(StatementScope statementScope, Object parameterObject) {
625
    Sql sql = statementScope.getSql();
1✔
626
    ParameterMap pmap = sql.getParameterMap(statementScope, parameterObject);
1✔
627
    CacheKey cacheKey = pmap.getCacheKey(statementScope, parameterObject);
1✔
628
    cacheKey.update(id);
1✔
629

630
    // I am not sure how any clustered cache solution would ever have had any cache hits against
631
    // replicated objects. I could not make it happen
632
    // The baseCacheKey value which was being used in the update below is consistent across
633
    // JVMInstances on the same machine
634
    // but it's not consistent across machines, and therefore breaks clustered caching.
635

636
    // What would happen is the cache values were being replicated across machines but there
637
    // were never any cache hits for cached objects on
638
    // anything but the original machine an object was created on.
639

640
    // After reviewing this implementation I could not figure out why baseCacheKey is used for
641
    // this anyway as it's not needed, so I removed it.
642
    // The values used from the pmap.getCacheKey, plus id, plus the params below are unique and
643
    // the same across machines, so now I get replicated
644
    // cache hits when I force failover in my cluster
645

646
    // I wish I could make a unit test for this, but I can't do it as the old implementation
647
    // works on 1 machine, but fails across machines.
648
    // cacheKey.update(baseCacheKey);
649

650
    cacheKey.update(sql.getSql(statementScope, parameterObject)); // Fixes bug 953001
1✔
651
    return cacheKey;
1✔
652
  }
653

654
  /**
655
   * Sets the base cache key.
656
   *
657
   * @param base
658
   *          the new base cache key
659
   */
660
  public void setBaseCacheKey(int base) {
661
    this.baseCacheKey = base;
1✔
662
  }
1✔
663

664
  /**
665
   * Adds the execute listener.
666
   *
667
   * @param listener
668
   *          the listener
669
   */
670
  public void addExecuteListener(ExecuteListener listener) {
671
    executeListeners.add(listener);
1✔
672
  }
1✔
673

674
  /**
675
   * Notify listeners.
676
   */
677
  public void notifyListeners() {
678
    for (Object executeListener : executeListeners) {
1✔
679
      ((ExecuteListener) executeListener).onExecuteStatement(this);
1✔
680
    }
1✔
681
  }
1✔
682

683
  /**
684
   * Gets the sql executor.
685
   *
686
   * @return the sql executor
687
   */
688
  public SqlExecutor getSqlExecutor() {
689
    return sqlMapClient.getSqlExecutor();
1✔
690
  }
691

692
  /**
693
   * Gets the sql map client.
694
   *
695
   * @return the sql map client
696
   */
697
  public SqlMapClient getSqlMapClient() {
698
    return sqlMapClient;
×
699
  }
700

701
  /**
702
   * Sets the sql map client.
703
   *
704
   * @param sqlMapClient
705
   *          the new sql map client
706
   */
707
  public void setSqlMapClient(SqlMapClient sqlMapClient) {
708
    this.sqlMapClient = (SqlMapClientImpl) sqlMapClient;
1✔
709
  }
1✔
710

711
  /**
712
   * Inits the request.
713
   *
714
   * @param statementScope
715
   *          the statement scope
716
   */
717
  public void initRequest(StatementScope statementScope) {
718
    statementScope.setStatement(this);
1✔
719
    statementScope.setParameterMap(parameterMap);
1✔
720
    statementScope.setResultMap(resultMap);
1✔
721
    statementScope.setSql(sql);
1✔
722
  }
1✔
723

724
  /**
725
   * Gets the timeout.
726
   *
727
   * @return the timeout
728
   */
729
  public Integer getTimeout() {
730
    return timeout;
1✔
731
  }
732

733
  /**
734
   * Sets the timeout.
735
   *
736
   * @param timeout
737
   *          the new timeout
738
   */
739
  public void setTimeout(Integer timeout) {
740
    this.timeout = timeout;
1✔
741
  }
1✔
742

743
  /**
744
   * Adds the result map.
745
   *
746
   * @param resultMap
747
   *          the result map
748
   */
749
  public void addResultMap(ResultMap resultMap) {
750
    List<ResultMap> resultMapList = Arrays.asList(additionalResultMaps);
1✔
751
    resultMapList = new ArrayList<>(resultMapList);
1✔
752
    resultMapList.add(resultMap);
1✔
753
    additionalResultMaps = resultMapList.toArray(new ResultMap[resultMapList.size()]);
1✔
754
  }
1✔
755

756
  /**
757
   * Checks for multiple result maps.
758
   *
759
   * @return true, if successful
760
   */
761
  public boolean hasMultipleResultMaps() {
762
    return additionalResultMaps.length > 0;
1✔
763
  }
764

765
  /**
766
   * Gets the additional result maps.
767
   *
768
   * @return the additional result maps
769
   */
770
  public ResultMap[] getAdditionalResultMaps() {
771
    return additionalResultMaps;
1✔
772
  }
773
}
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