File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
core/src/main/java/org/sql2o Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -800,7 +800,7 @@ public boolean isExplicitExecuteBatchRequired(){
800800 * Adds a set of parameters to this <code>Query</code>
801801 * object's batch of commands. <br/>
802802 *
803- * If maxBatchRecords is more than 0, executeBatch is called upon adding that manny
803+ * If maxBatchRecords is more than 0, executeBatch is called upon adding that many
804804 * commands to the batch. <br/>
805805 *
806806 * The current number of batched commands is accessible via the <code>getCurrentBatchRecords()</code>
@@ -821,6 +821,26 @@ public Query addToBatch(){
821821 return this ;
822822 }
823823
824+ /**
825+ * Adds a set of parameters to this <code>Query</code>
826+ * object's batch of commands and returns any generated keys. <br/>
827+ *
828+ * If maxBatchRecords is more than 0, executeBatch is called upon adding that many
829+ * commands to the batch. This method will return any generated keys if <code>fetchGeneratedKeys</code> is set. <br/>
830+ *
831+ * The current number of batched commands is accessible via the <code>getCurrentBatchRecords()</code>
832+ * method.
833+ */
834+ public <A > List <A > addToBatchGetKeys (Class <A > klass ){
835+ this .addToBatch ();
836+
837+ if (this .currentBatchRecords == 0 ) {
838+ return this .connection .getKeys (klass );
839+ } else {
840+ return Collections .emptyList ();
841+ }
842+ }
843+
824844 public Connection executeBatch () throws Sql2oException {
825845 long start = System .currentTimeMillis ();
826846 try {
You can’t perform that action at this time.
0 commit comments