-
Notifications
You must be signed in to change notification settings - Fork 12
implement java.sql.PreparedStatement #24
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
implement java.sql.PreparedStatement #24
Conversation
| setParameter(parameterIndex, BsonNull.VALUE); | ||
| } | ||
|
|
||
| private void setBsonDateTimeParameter(int parameterIndex, java.util.@Nullable Date date) throws SQLException { |
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.
It is very weird that the following @Nullable is disallowed:
@Nullable java.util.Date date
No clue on jspecify doc.
…ng nullness warnings as well).
… MongoPreparedStatement for we only use its `getTime()` method
| @Override | ||
| public int executeUpdate() throws SQLException { | ||
| checkClosed(); | ||
| return executeUpdate(command); |
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.
In POC (and in tech doc), we implemented by invoking parent class or MongoStatement's executeUpdate(String mql) but I think it is not the best for some reasons:
- we need to parse mql again unnecessarily; passing command directly to a new protected method accepting a parsed command makes more sense
- we had to solve the parameters in
Statementclass which should know nothing aboutPreparedStatementparameter concern; passing a command with all parameters resolved makes more sense
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.
The last reviewed commit is 5c63de4.
src/main/java/com/mongodb/hibernate/jdbc/PreparedStatementAdapter.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/com/mongodb/hibernate/jdbc/MongoPreparedStatementIntegrationTests.java
Outdated
Show resolved
Hide resolved
src/test/java/com/mongodb/hibernate/jdbc/MongoPreparedStatementTests.java
Outdated
Show resolved
Hide resolved
src/test/java/com/mongodb/hibernate/jdbc/MongoPreparedStatementTests.java
Outdated
Show resolved
Hide resolved
src/test/java/com/mongodb/hibernate/jdbc/MongoPreparedStatementTests.java
Outdated
Show resolved
Hide resolved
…redStatementIntegrationTests.java Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
…MongoPreparedStatementTests
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.
The last reviewed commit is 17dd554.
Thanks. I'd learned to avoid the mistake of missing the middle 'hidden part' so I think I might well not rely on this manual marker any more, :). |
|
|
||
| private void checkParameterIndex(int parameterIndex) throws SQLException { | ||
| if (parameterValueSetters.isEmpty()) { | ||
| throw new SQLException("No parameter exists"); |
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.
I found an edge. case above. If the parameter list is empty, the below exception message would be invalid.
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.
The last reviewed commit is 96692d6.
src/main/java/com/mongodb/hibernate/jdbc/MongoPreparedStatement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/mongodb/hibernate/jdbc/MongoPreparedStatement.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.
The last reviewed commit is 412f38f.
src/test/java/org/mockito/configuration/MockitoConfiguration.java
Outdated
Show resolved
Hide resolved
src/test/java/org/mockito/configuration/MockitoConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/mongodb/hibernate/jdbc/MongoPreparedStatement.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
…ts and MongoStatementTests
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.
I don't plan to review this further so LGTM-ing to allow merge when Valentin approves.
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.
The last reviewed commit is 30004df.
There is only one unaddressed concern left.
Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
I overlooked the comment regarding the removal of |
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.
The last reviewed commit is 038ec75.
https://jira.mongodb.org/browse/HIBERNATE-13
Implementing
java.sql.PreparedStataementis the last blocker to go about CRUD MQL translation (R oraggregatehas to be postponed later as planned). We decided to use the{ $undefined: true }as the MQL parameter placeholder (later PR will deal with how to generate it during MQL translation) as opposed to the standardized JDBC?marker.Both unit testing and a simple integration testing case are included.