Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto_batch_dml methods + combination with JDBC batching #1795

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

olavloite
Copy link
Collaborator

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.

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 olavloite requested a review from a team as a code owner October 21, 2024 16:13
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels Oct 21, 2024
@olavloite olavloite requested a review from a team as a code owner October 22, 2024 07:54
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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -401,15 +400,6 @@ void checkAndSetBatchType(String sql) throws SQLException {
}
}

private void checkConnectionHasNoActiveBatch() throws SQLException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@olavloite olavloite merged commit 98f01bb into main Oct 25, 2024
23 checks passed
@olavloite olavloite deleted the auto-batch-dml-methods branch October 25, 2024 09:24
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants