Skip to content

Commit

Permalink
Fix parameter batches multiple executions
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasHafner committed Apr 24, 2024
1 parent a4a7600 commit 2cfb59d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public class PolyphenyPreparedStatement extends PolyphenyStatement implements PreparedStatement {

private TypedValue[] parameters;
private final List<List<TypedValue>> parameterBatch = new LinkedList<>();
private List<List<TypedValue>> parameterBatch = new LinkedList<>();
private final PolyphenyParameterMetaData parameterMetaData;


Expand Down Expand Up @@ -350,6 +350,10 @@ public void clearParameters() throws SQLException {
parameters = createParameterList( parameterMetaData.getParameterCount() );
}

private void clearParameterBatch() {
parameterBatch = new LinkedList<>();
}


@Override
public void setObject( int parameterIndex, Object x, int targetSqlType ) throws SQLException {
Expand Down Expand Up @@ -420,7 +424,8 @@ public int[] executeBatch() throws SQLException {
private List<Long> executeParameterizedBatch() throws SQLException {
throwIfClosed();
StatementBatchResponse status = getClient().executeIndexedStatementBatch( statementId, parameterBatch, getTimeout() );
clearParameters();
// jdbc: only batch is cleared, parameters remain beyond executions
clearParameterBatch();
return status.getScalarsList();
}

Expand Down

0 comments on commit 2cfb59d

Please sign in to comment.