-
Notifications
You must be signed in to change notification settings - Fork 427
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
[FEATURE REQUEST] Allow sending UUID in binary to database #1582
Comments
Hi Knutwannheden, This looks like a possible improvement to add in the future. It looks like this separation in flow was deliberately put in place, so there is risk of breaking something if we are not careful. Regardless it has been backlogged. |
Looking at the code, it seems that there is currently no way to pass a UUID as a I may contribute a PR for this feature. |
* Added support for TDSType.GUID (#1582) * Fix UUID serialisation * Add unit tests * Fix typo, handle PR feedback --------- Co-authored-by: Cédric de Launois <[email protected]> Co-authored-by: Cédric de Launois <>
re-opening since PR #2324 was reverted |
Thanks for fixing this! I do have a small comment, however: To me it looks like the implementation currently requires the |
Indeed PR #2370 is required but does not fully cover this feature request. |
Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it
I am trying to execute SQL queries with
UUID
objects in Java mapping touniqueidentifier
values in the database. This works, but when passing aUUID
value as an input to a query usingPreparedStatement#setObject()
the value ends up being transferred as a string over the wire. This is inefficient both computationally (UUID#toString()
) and also transfers more data over the network (36 bytes vs. 16 bytes).Describe the preferred solution
When reading
uniqueidentifier
values from aResultSet
I can callResultSet#getObject(int, Class)
with the second parameter asUUID.class
. This will give back the correct UUID value as expected without first converting the byte array to a String. Essentially I would want to have the same possibility when callingPreparedStatement#setObject()
with aUUID
object as input.Describe alternatives you've considered
The alternative (workaround) I now use to do this is to manually convert the
UUID
value to abyte[]
value (essentially using the same logic as inUtil#asGuidByteArray(UUID)
) and then give thatbyte[]
object toPreparedStatement#setObject()
.Additional context
Looking at the code I found this relevant block:
mssql-jdbc/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
Lines 1597 to 1606 in 1f550f1
Apparently it looks like what I want is possible, but only when
cryptoMeta
is set. I don't understand how encryption is related to this.Reference Documentations/Specifications
Reference Implementation
The text was updated successfully, but these errors were encountered: