feat: auto_batch_dml methods + combination with JDBC batching#1795
Merged
feat: auto_batch_dml methods + combination with JDBC batching#1795
Conversation
Adds methods for enabling/disabling auto_batch_dml. Also enables the use of this feature in combination with other JDBC batches. This again allows PreparedStatement#addBatch() and Statement#addBatch(String) to be used in combination with auto_batch_dml. This again makes it usable in combination with frameworks like Hibernate.
olavloite
commented
Oct 22, 2024
Comment on lines
-105
to
-110
| // skipping the test when dialect is POSTGRESQL because of exception below | ||
| // INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Statements with set | ||
| // operations in subqueries are not supported | ||
| assumeFalse( | ||
| "select array of structs is not supported on POSTGRESQL", | ||
| dialect.dialect == Dialect.POSTGRESQL); |
Collaborator
Author
There was a problem hiding this comment.
This is unrelated to this change, but cleaning it up now that we're touching this file anyways; This limitation no longer applies to PostgreSQL-dialect databases.
| try (Connection connection = createConnection(env, database)) { | ||
| connection.createStatement().execute("START BATCH DML"); | ||
| connection.createStatement().addBatch("INSERT INTO Singers (SingerId) VALUES (-1)"); | ||
| fail("missing expected exception"); |
Collaborator
Author
There was a problem hiding this comment.
This limitation has been lifted in the Java Connection API, which means that we can now allow this in the JDBC driver as well. Executing a DML batch when a batch is already active, is supported and just adds these batched statements to the active batch.
| } | ||
| } | ||
|
|
||
| private void checkConnectionHasNoActiveBatch() throws SQLException { |
Collaborator
Author
There was a problem hiding this comment.
This check is no longer needed, as the Java Connection API now allows us to 'execute a batch in a batch'. The statements that are executed in this batch, are just added to the existing batch on the connection.
rayudu3745
approved these changes
Oct 25, 2024
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Oct 25, 2024
🤖 I have created a release *beep* *boop* --- ## [2.24.0](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.23.0...v2.24.0) (2024-10-25) ### Features * Auto_batch_dml methods + combination with JDBC batching ([#1795](https://togithub.com/googleapis/java-spanner-jdbc/issues/1795)) ([98f01bb](https://togithub.com/googleapis/java-spanner-jdbc/commit/98f01bba45ec299182d0501c8f43e161d14cf78b)) ### Dependencies * Update dependency com.google.cloud:google-cloud-spanner-bom to v6.80.0 ([#1804](https://togithub.com/googleapis/java-spanner-jdbc/issues/1804)) ([55d6eef](https://togithub.com/googleapis/java-spanner-jdbc/commit/55d6eef81026d3dd94d80c4cab004152a82e2e67)) * Update dependency com.google.cloud:sdk-platform-java-config to v3.38.0 ([#1800](https://togithub.com/googleapis/java-spanner-jdbc/issues/1800)) ([f52a087](https://togithub.com/googleapis/java-spanner-jdbc/commit/f52a087f72b0fab8193ecaec454c52ee71ebcda3)) * Update dependency org.springframework.boot:spring-boot to v3.3.5 ([#1801](https://togithub.com/googleapis/java-spanner-jdbc/issues/1801)) ([44b756d](https://togithub.com/googleapis/java-spanner-jdbc/commit/44b756db18c79d2ae7fc01150cea33c411f5afbc)) * Update dependency org.springframework.boot:spring-boot-starter-data-jdbc to v3.3.5 ([#1802](https://togithub.com/googleapis/java-spanner-jdbc/issues/1802)) ([7709c98](https://togithub.com/googleapis/java-spanner-jdbc/commit/7709c988043e06b15e6ace6a6759594bbfeeace8)) * Update dependency org.springframework.boot:spring-boot-starter-parent to v3.3.5 ([#1803](https://togithub.com/googleapis/java-spanner-jdbc/issues/1803)) ([c452a37](https://togithub.com/googleapis/java-spanner-jdbc/commit/c452a375be26f2d43e1d76056bd45d486340c73f)) * Update dependency org.springframework.data:spring-data-bom to v2024.0.5 ([#1793](https://togithub.com/googleapis/java-spanner-jdbc/issues/1793)) ([5bd5a0a](https://togithub.com/googleapis/java-spanner-jdbc/commit/5bd5a0a086a8e38709a851cdd2fbb2bc28dbe3a5)) * Update dependency org.testcontainers:testcontainers to v1.20.3 ([#1798](https://togithub.com/googleapis/java-spanner-jdbc/issues/1798)) ([c643c33](https://togithub.com/googleapis/java-spanner-jdbc/commit/c643c3365f435db2b04a001ce0b9bbb997e2b4f3)) * Update dependency org.testcontainers:testcontainers-bom to v1.20.3 ([#1799](https://togithub.com/googleapis/java-spanner-jdbc/issues/1799)) ([da1acfc](https://togithub.com/googleapis/java-spanner-jdbc/commit/da1acfc1e63d8afe4a4c5a51e2f155cd42d89e1d)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds methods for enabling/disabling auto_batch_dml.
Also enables the use of this feature in combination with other JDBC batches. This again allows PreparedStatement#addBatch() and Statement#addBatch(String) to be used in combination with auto_batch_dml. This again makes it usable in combination with frameworks like Hibernate.