SQL Server UNIQUEIDENTIFIER type uses an uppercase UUID String representation

Description

As documented in this forum thread, SQL Server uses an uppercase representation for UUIDs.

If we use the UUID or byte[] UUID identifiers, everything works just fine. But if we use a String identifier, then the UUID.toString() will return a lowercase String representation (which is according to the UUID specs). However, SQL Server uses an uppercase UUID String representation, and this can cause issues when fetching FK associations.

After analyzing this issue, I came to realize that, instead of fixing anything in Hibernate, the user can workaround this SQL Server limitation by using an uppercase identifier:

This will work for field-based access. For property-based access, you could use a byte[] for the identifier, and have a method to transform the byte[] to a String for the UI. Just make sure that, internally, the byte[] is used, not the String one.

Activity

Show:

Vlad Mihalcea September 3, 2018 at 7:29 AM

Better use the workaround as stated in the issue description. I added some tests though to demonstrate that byte[], UUID and the uppercase String identifier work just fine on SQL Server.

Won't Fix

Details

Assignee

Reporter

Components

Priority

Created September 3, 2018 at 7:24 AM
Updated December 3, 2024 at 9:26 AM
Resolved September 3, 2018 at 7:29 AM