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

mybatis / ibatis-2 / #341

08 Sep 2023 11:16PM UTC coverage: 64.938% (+0.03%) from 64.913%
#341

push

github

web-flow
Merge pull request #183 from hazendaz/master

fixes #174, update GHA, maven wrapper, fix EOL markers, do not use star imports

5047 of 7772 relevant lines covered (64.94%)

0.65 hits per line

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

87.64
/src/main/java/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.java
1
/*
2
 * Copyright 2004-2023 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.parsers.DocumentBuilder;
43
import javax.xml.parsers.DocumentBuilderFactory;
44

45
import org.w3c.dom.Document;
46

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

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

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

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

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

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

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

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

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

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

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

82
  /** The additional result maps. */
83
  private ResultMap[] additionalResultMaps = new ResultMap[0];
1✔
84

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

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

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

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

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

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

127
      Sql sql = getSql();
1✔
128

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

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

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

138
      int rows = 0;
1✔
139

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

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

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

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

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

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

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

195
      if (list.size() > 1) {
1✔
196
        throw new SQLException("Error: executeQueryForObject returned too many results.");
×
197
      } else if (list.size() > 0) {
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
    } else {
374
      return getSqlExecutor().executeUpdate(statementScope, conn, sqlString, parameters);
1✔
375
    }
376
  }
377

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

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

444
  /**
445
   * String to document.
446
   *
447
   * @param s
448
   *          the s
449
   *
450
   * @return the document
451
   */
452
  private Document stringToDocument(String s) {
453
    try {
454
      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
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 accross 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 implementaion
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 (int i = 0, n = executeListeners.size(); i < n; i++) {
1✔
679
      ((ExecuteListener) executeListeners.get(i)).onExecuteStatement(this);
1✔
680
    }
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 resultMapList = Arrays.asList(additionalResultMaps);
1✔
751
    resultMapList = new ArrayList(resultMapList);
1✔
752
    resultMapList.add(resultMap);
1✔
753
    additionalResultMaps = (ResultMap[]) 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