-
Notifications
You must be signed in to change notification settings - Fork 12
Introduce batch support. #127
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces batch support to the MongoDB Hibernate integration, enabling efficient bulk operations through JDBC PreparedStatement batching. It refactors the execution model from individual command execution to bulk write operations using MongoDB's driver bulk API.
- Implements batch operations support for PreparedStatement (addBatch, clearBatch, executeBatch)
- Refactors MongoStatement to use MongoDB bulk write operations instead of individual commands
- Adds comprehensive test coverage for batch insert, update, and delete operations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
MongoPreparedStatementTests.java | Updates unit tests to reflect bulk write operations and adds new batch execution error handling tests |
MongoStatement.java | Refactors execution from runCommand to bulkWrite operations and adds bulk write model conversion |
MongoPreparedStatement.java | Implements batch support methods and batch exception handling |
BatchUpdateIntegrationTests.java | New integration test file for testing batch operations in real Hibernate scenarios |
AbstractQueryIntegrationTests.java | Updates test utilities to support multiple command assertions |
MongoPreparedStatementIntegrationTests.java | Adds comprehensive integration tests for batch operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/integrationTest/java/com/mongodb/hibernate/query/mutation/BatchUpdateIntegrationTests.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/com/mongodb/hibernate/jdbc/MongoPreparedStatementIntegrationTests.java
Outdated
Show resolved
Hide resolved
@Override | ||
public void addBatch(String mql) throws SQLException { | ||
checkClosed(); | ||
throw new SQLFeatureNotSupportedException("TODO-HIBERNATE-35 https://jira.mongodb.org/browse/HIBERNATE-35"); | ||
} | ||
|
||
@Override | ||
public void clearBatch() throws SQLException { | ||
checkClosed(); | ||
throw new SQLFeatureNotSupportedException("TODO-HIBERNATE-35 https://jira.mongodb.org/browse/HIBERNATE-35"); | ||
} | ||
|
||
@Override | ||
public int[] executeBatch() throws SQLException { | ||
checkClosed(); | ||
closeLastOpenResultSet(); | ||
throw new SQLFeatureNotSupportedException("TODO-HIBERNATE-35 https://jira.mongodb.org/browse/HIBERNATE-35"); | ||
} |
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.
These are not implemented because Hibernate relies on PreparedStatement methods for batching.
https://jira.mongodb.org/browse/HIBERNATE-40
https://jira.mongodb.org/browse/HIBERNATE-35