score:0
With the generator, you specified you generate UUIDs on the application side and send them to the database where they are stored in an efficient format which most certainly doesn't include any information about upper and lower case because it is just a number.
I suspect the difference you see in your selects probably comes from the Session cache and doesn't really have much to do with the method you use: If the entity is found in the cache it get's returned and if it was just saved it contains the UUID in the format the Hibernator generated it (so upper-lower case depends on a toString()
method in Hibernate).
If the entity is not found in the cache it is returned as it comes from the database which most likely depends on an implementation detail in the JDBC driver you use.
So how to fix this:
The easy way: Use guid
as the generator. It will hit the database so the UUID will always be in the format provided by the database. If performance is critical this is probably not a viable option. Note: I couldn't find this generator in the current documentation, no idea if it is deprecated or something.
The hard way: Find or create a UUID generator that creates the UUIDs in the exact format that is returned by the database.
There seems to be a surprising amount of wiggle room for the generation of UUIDs so here is a list of links for further reading:
Vlad Mihalcea about UUIDs: https://vladmihalcea.com/hibernate-and-uuid-identifiers/
A somewhat similar issue: Different representation of UUID in Java Hibernate and SQL Server
The current version of the Hibernate documentation about UUID.
score:0
Why not just convert all the strings to the same case (which doesn't matter) before comparing them?
Still, this doesn't seem ideal; comparing two strings that are 36 characters long is going to take more time (and handling them will take more space) than 16-byte numbers, and since the database is (you hope) storing them as binary, you have the extra cost of conversions to that less efficient form. Oh, and the string comparison will be slower even for the same number of bytes because it doesn't know they're fixed length, it it probably has to compare a byte at a time rather than using wider compares.
More questions
- Repository.findAll() returning capitalized UUIDs?
- How to do join on multiple criteria, returning all combinations of both criteria
- SELECT max(x) is returning null; how can I make it return 0?
- tsql returning a table from a function or store procedure
- SQL: Update a row and returning a column value with 1 query
- NOT LIKE and LIKE not returning opposite result
- SQL Server @@SERVERNAME returning old machine name?
- Returning multiple tables from a stored procedure
- How do I execute a MS SQL Server stored procedure in java/jsp, returning table data?
- ExecuteScalar vs ExecuteNonQuery when returning an identity value
- Why is IS NOT NULL returning NULL values for a Varchar(max) in SQL Server?
- Executing SQL Server Agent Job from a stored procedure and returning job result
- Returning table with CLR
- Returning multiple values from a stored procedure
- Clarification as to why EXECUTE AS USER/LOGIN is not returning the expected results?
- Inner join returning more rows then exist in tables
- Outer Apply Returning columns unexpectedly NOT NULL when no match
- Stored procedure is not returning data
- JDBC getUpdateCount is returning 0, but 1 row is updated, in SQL Server
- Avoid returning result set from stored procedure
- Dynamic SQL not returning results in Access pass-through query
- What happens with returning IEnumerable if used with async/await (streaming data from SQL Server with Dapper)?
- NodeJS MSSQL .query returning double data in both recordsets and recordset
- EF returning different values than query
- Blank values in Date column returning as 1900/01/01 on running SELECT statement
- C# + SQL Server ExecuteScalar() not returning last inserted id
- What to use for Size argument in Database.AddOutParameter when returning a string?
- SQL Server - returning xml child nodes for xml column
- Query returning all system stored procedures listed by MS SQL Server
- My PIVOT is returning duplicate rows with pivot column values in each row
More questions with similar tag
- How can I query a table with key/value pairs into a JSON object using FOR JSON PATH?
- SQL Server - adding Created Date to a column
- SQL: UN-PIVOT and separate by individual score
- How to write query in ORACLE and SQL_SERVER to get records with the most statuses?
- How to get Minimum minimum value of a row in sql
- Calculating cumulative sum in ms-sql
- Dynamic Google doughnut chart from sql query data
- Efficiently using manual data synchronization between SQL Server Compact and WCF service
- After delete insert value in SQL Server
- Proper way to send result of a T-SQL query to a file
- SQL performance MAX()
- SQL Server Pre-Login Handshake (error: 31 - Encryption(ssl/tls) handshake failed)
- Add DELETE to query that returns duplicate records | SQL Server
- Calculate one sql query as the percentage of another?
- if there is any technique to insert values into multiple tables in sql Server 2008 Database?
- Script to filter by most recent end of week date
- SQL (local) does not work
- Which one is the best method to replicate a database in SQL Server?
- How to use window function to aggregate data based on date or rank column?
- Query error IN GROUP BY
- EF: Passing a table valued parameter to a user-defined function from C#
- PIVOT columns in SQL Server with their SUM
- Please help explain if I'm destroying my DB Schema for the sake of performance :(
- SQL server transaction
- Unable to begin a distributed transaction
- How to split a table into Master/Detail, with generating id SSIS?
- t-sql string & table column manipulation
- Regular Expression for validating Website URL in SQL Server
- Delete unattached data
- GSS-API MSSQL JDBC Driver