-
Notifications
You must be signed in to change notification settings - Fork 356
GH-1159 Batch Insert Operations Within a Single Aggregate #1191
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
Conversation
213a801
to
e5d6272
Compare
...-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BatchInsertStrategy.java
Show resolved
Hide resolved
...data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java
Outdated
Show resolved
Hide resolved
...data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java
Outdated
Show resolved
Hide resolved
...data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java
Outdated
Show resolved
Hide resolved
...data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java
Outdated
Show resolved
Hide resolved
...g-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java
Outdated
Show resolved
Hide resolved
...g-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java
Outdated
Show resolved
Hide resolved
...g-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the old method signatures: They should behave as close to the original as possible. If they don't work for certain cases we need to identify those cases in order to decide if we can go forward with this, or if we have to move the change to the next major release.
...-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BatchJdbcOperations.java
Outdated
Show resolved
Hide resolved
...-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BatchJdbcOperations.java
Outdated
Show resolved
Hide resolved
...-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BatchJdbcOperations.java
Outdated
Show resolved
Hide resolved
...ces/org.springframework.data.jdbc.repository/JdbcRepositoryWithListsIntegrationTests-db2.sql
Show resolved
Hide resolved
And please squash the actual feature in a single commit ,please. |
I removed my previous default implementation for the deprecated |
370e08f
to
295ac39
Compare
+ Group into batches when populating AggregateChange based on the presence/absence of a value for @id. + Add Dialect IdGeneration property to indicate support for batch operations. No support by SqlServer and DB2 Dialects.
295ac39
to
26904fc
Compare
Thanks, that's merged. |
BatchJdbcOperations is still there, but deprecated, and not used except for deprecated places kept for backward compatibility. This is possible since Spring Framework made the features offered by `BatchJdbcOperations` part of `NamedParameterJdbcOperations`. See spring-projects/spring-framework#28132 See #1191
This improves the strategy for inserting entities referenced by aggregate to perform a batch insert when there are multiple entities in a collection.
This is only possible for databases which support retrieving generated keys for batch operations through
Statement#getGeneratedKeys
, which includes all currently supported databases other than DB2 and MS SQL Server. Note: DB2 does support this functionality outside of the JDBC spec withDB2PreparedStatement#getDBGeneratedKeys
.This implementation includes low level code in
BatchJdbcOperations
for performing the batch insert with aKeyHolder
andString[] keyColumnNames
which has largely been copied from spring frameworkspring-jdbc
, pending the acceptance of a proposal to add native support via additionalNamedParameterJdbcOperations#batchUpdate
methods. If and when this proposal is accepted and merged,BatchJdbcOperations
can be deleted and callers into it can be replaced with calls intoNamedParameterJdbcOperations
.Caveats:
AggregateChange
to be executed, inserts for a given referenced collection of entities are grouped into batches based on the presence/absence of an id value. Since this is determined only once rather than with every jdbc operation, this will produce unexpected results for any existingBeforeSaveCallback
that is setting the value of an@Id
annotated property. Any such operation will need to be moved toBeforeConvertCallback
in order to continue working as expected.MyBatisDataAccessStrategy
at this time. When used, this will process the batch insert as serial inserts.Closes #1159