You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/08/15 07:14:29 UTC
groovy git commit: Factorizes batchCount incrementation and thus
executeBatch() execution (close #585)
Repository: groovy
Updated Branches:
refs/heads/master 9dc46078d -> c3803f9bd
Factorizes batchCount incrementation and thus executeBatch() execution (close #585)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c3803f9b
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c3803f9b
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c3803f9b
Branch: refs/heads/master
Commit: c3803f9bd85e972ef4541997a74c903b3fbeddd3
Parents: 9dc4607
Author: Antoine Kapps <an...@zas.admin.ch>
Authored: Mon Aug 14 18:03:35 2017 +0200
Committer: paulk <pa...@asert.com.au>
Committed: Tue Aug 15 17:13:44 2017 +1000
----------------------------------------------------------------------
.../java/groovy/sql/BatchingPreparedStatementWrapper.java | 7 +------
.../src/main/java/groovy/sql/BatchingStatementWrapper.java | 8 ++++++++
2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/c3803f9b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingPreparedStatementWrapper.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingPreparedStatementWrapper.java b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingPreparedStatementWrapper.java
index 9243266..3a4dc0a 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingPreparedStatementWrapper.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingPreparedStatementWrapper.java
@@ -60,11 +60,6 @@ public class BatchingPreparedStatementWrapper extends BatchingStatementWrapper {
sql.setParameters(parameters, delegate);
}
delegate.addBatch();
- batchCount++;
- if (batchCount == batchSize /* never true for batchSize of 0 */) {
- int[] result = delegate.executeBatch();
- processResult(result);
- batchCount = 0;
- }
+ incrementBatchCount();
}
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/c3803f9b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java
index a5cecc2..edb5212 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java
@@ -59,6 +59,14 @@ public class BatchingStatementWrapper extends GroovyObjectSupport {
public void addBatch(String sql) throws SQLException {
delegate.addBatch(sql);
+ incrementBatchCount();
+ }
+
+ /**
+ * Increments batch count (after addBatch(..) has been called)
+ * and execute {@code delegate.executeBatch()} if batchSize has been reached.
+ */
+ protected void incrementBatchCount() throws SQLException {
batchCount++;
if (batchCount == batchSize /* never true for batchSize of 0 */) {
int[] result = delegate.executeBatch();