Temporary tables created in SQLServer use the collation for tempdb, not the application database
Description
The use of temporary tables for updates in SQLServer will fail if tempdb uses a different collation to the application db. Specifically, comparisons between the primary table columns and the temporary table columns fail.
It is unclear to me under what circumstances a temporary table is created, so I'm afraid no test case is attached. I do however attach modified versions of the following classes:
These resolve the issue, but the solution may not be the most optimal possible, as it involves intervention in a specific position (between the datatype declaration and any nullability clause)
Attachments
6
Activity
Show:
Nathan XuAugust 14, 2020 at 6:13 PM
I created a PR for it here:
François DambrineAugust 14, 2020 at 12:44 PM
As of 5.4.19 the bug is still there and prevent some update query to be executed as seen in
Is there a workaround for this bug?
David GoodJune 3, 2008 at 3:52 PM
The older versions of the attachments should disregarded - they will cause a failure if any of the temporary table's columns is not of the *char variety.
David GoodJune 3, 2008 at 3:45 PM
Add column parameter to getCreateTemporaryTableColumnAnnotation
David GoodJune 3, 2008 at 3:42 PM
Fix to allow annotation to be varied depending on column type
The use of temporary tables for updates in SQLServer will fail if tempdb uses a different collation to the application db. Specifically, comparisons between the primary table columns and the temporary table columns fail.
It is unclear to me under what circumstances a temporary table is created, so I'm afraid no test case is attached. I do however attach modified versions of the following classes:
org.hibernate.mapping.Table
org.hibernate.dialect.Dialect
org.hibernate.dialect.SQLServerDialect
These resolve the issue, but the solution may not be the most optimal possible, as it involves intervention in a specific position (between the datatype declaration and any nullability clause)