-
Notifications
You must be signed in to change notification settings - Fork 3
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.Statement #18
base: main
Are you sure you want to change the base?
Conversation
@@ -76,8 +76,6 @@ tasks.withType<JavaCompile>().configureEach { | |||
options.errorprone { | |||
disableWarningsInGeneratedCode.set(true) | |||
option("NullAway:AnnotatedPackages", "com.mongodb.hibernate") | |||
option("NullAway:ExcludedFieldAnnotations", "org.mockito.Mock") | |||
option("NullAway:ExcludedFieldAnnotations", "org.mockito.InjectMocks") |
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.
found the above two options not taking effect
@@ -272,11 +273,11 @@ public void clearWarnings() throws SQLException { | |||
@Override | |||
public <T> T unwrap(Class<T> unwrapType) throws SQLException { | |||
checkClosed(); | |||
throw new SQLFeatureNotSupportedException("Unwrap() unsupported"); | |||
throw new SQLFeatureNotSupportedException("unwrap unsupported"); |
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.
simulating the message pattern elsewhere
} | ||
|
||
@Override | ||
public boolean isWrapperFor(Class<?> iface) throws SQLException { | ||
public boolean isWrapperFor(Class<?> iface) { |
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.
seems we'd better eliminate unused exceptions from method signature to avoid troubling method user to catch the checked exception which will never be thrown.
default: | ||
throw new SQLFeatureNotSupportedException( | ||
"Unsupported (supported commands include 'insert', 'update' and 'delete') command: " | ||
+ commandName); |
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.
we might need dicusson on what commands we support. The above three was copied from POC, not necessarily the best.
c735032
to
e5fb484
Compare
e5fb484
to
092047c
Compare
https://jira.mongodb.org/browse/HIBERNATE-16
java.sql.Statement
is the parent class ofjava.sql.PreparedStatement
, which mainly focused on parameterization. Internally after parameters passed intoPreparedStatement
are collected and resolved, the resulting SQL would still be executed injava.sql.Statement
, including:We have separate tickets for the first and third entry above, but the second entry is in the scope of this PR. The method parameter or
sql
could come from HQL or native MQL. Regardless, for now we simply feed it (parameterization from HQL will be done in another ticket implementingjava.sql.PreparedStatement
) to Mongo Java driver.The implementation internally is based on
MongoDatabase#runCommand(ClientSession, Bson)
, so we need to passMongoDatabase
all the way fromMongoConnectionProvider
. Currently a@Nullable
MongoDatabase
will be used for now and it could be changed later (when we finished discussion on how to get database somewhere).Most of the unit testing focused on the edge cases of
int executeUpdate(String)
by mocking. After evergreen integration work is done, we might later add integration testing cases on it.