Skip to content

feat: Add batch support to Statement implementation#1296

Merged
michael-simons merged 2 commits intomainfrom
feature/statement-batch-support
Mar 11, 2026
Merged

feat: Add batch support to Statement implementation#1296
michael-simons merged 2 commits intomainfrom
feature/statement-batch-support

Conversation

@michael-simons
Copy link
Collaborator

Summary

  • Implement addBatch(String), clearBatch(), and executeBatch() on StatementImpl, replacing the previous SQLFeatureNotSupportedException stubs
  • Each batch entry is executed via executeUpdate0 with SQL processing enabled, supporting both Cypher and SQL statements
  • Failures throw BatchUpdateException with partial results per the JDBC specification
  • Guard individual statement execution (executeQuery, executeUpdate, execute) when a batch is pending, requiring the batch to be executed or cleared first

Test plan

  • shouldExecuteBatchWithCypher — multiple Cypher CREATE statements, verify node counts
  • shouldExecuteBatchWithSQL — SQL INSERT statements with translation enabled
  • shouldClearBatch — verify clearBatch() resets, executeBatch() returns empty array
  • shouldThrowOnAddBatchWhenClosed — closed statement throws SQLException
  • shouldThrowOnAddBatchWithNullSQL — null SQL throws SQLException
  • shouldExecuteEmptyBatch — empty batch returns empty int[]
  • shouldRejectExecuteQueryWhenBatchPendingexecuteQuery blocked by pending batch
  • shouldRejectExecuteUpdateWhenBatchPendingexecuteUpdate blocked by pending batch
  • shouldRejectExecuteWhenBatchPendingexecute blocked by pending batch
  • shouldAllowExecuteAfterClearBatch — normal execution works after clearing
  • shouldAllowExecuteAfterExecuteBatch — normal execution works after batch execution

🤖 Generated with Claude Code

michael-simons and others added 2 commits March 11, 2026 15:25
Implement `addBatch(String)`, `clearBatch()`, and `executeBatch()` for
`StatementImpl`, bringing plain `Statement` in line with the JDBC spec.
Individual statements in the batch are executed via `executeUpdate0` with
SQL processing enabled, supporting both Cypher and SQL. Failures throw
`BatchUpdateException` with partial results per the JDBC contract.

Also guard against executing individual statements while a batch is
pending, requiring the batch to be executed or cleared first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The unit tests in `StatementImplTests` expected `addBatch`, `clearBatch`,
and `executeBatch` to throw `SQLFeatureNotSupportedException`, which is
no longer correct after implementing batch support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@michael-simons michael-simons merged commit 9a0e866 into main Mar 11, 2026
10 checks passed
@michael-simons michael-simons deleted the feature/statement-batch-support branch March 11, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants