You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hibernate 7: support DB2 in the unique key null handling, and test it #16746
The code that chooses how a unique key is built or read for a nullable key treats DB2 like H2, PostgreSQL, MySQL, MariaDB and SQL Server: a row with a null in the key never conflicts. That is not verified for DB2 and may be wrong.
Hibernate creates DB2's unique key as create unique index ... exclude null keys (DB2Dialect#getCreateIndexTail; AlterTableUniqueIndexDelegate says DB2 does not allow unique constraints on nullable columns). As far as I know, exclude null keys leaves out an entry only when all of its key columns are null, and DB2 compares the other nulls as equal, so ('en', null) twice would conflict, as on Oracle. Nobody has run this on DB2.
Where the assumption is made
UniqueIndexNulls (Hibernate 7: write the rows of unidirectional hasMany collections that share a join table #16701): maps only OracleDialect to COMPARED, every other dialect, DB2 included, to DISTINCT. SharedJoinTableUniqueness builds one unique key per association for DISTINCT. On DB2, if nulls are compared, two associations that share a key column, or owners that share an element, would be rejected on legitimate rows.
A DB2 container spec (Testcontainers db2 module, icr.io/db2_community/db2) added to the database matrix of SharedJoinTableHibernate7Spec, SharedKeyColumnHibernate7Spec and UniqueNullsHibernate7Spec, so the behavior is measured and not read from the source.
If DB2 compares partly null keys, give it the COMPARED / value reading, with the DDL in SharedJoinTableUniqueKeyBinderSpec adjusted, and correct the documentation tables.
Say in the documentation which databases the tests cover.
The unit-level DDL specs only show the DDL Hibernate renders. They do not show how DB2 treats the index.
Fixed by #16750 (Hibernate 7: unique key nulls, regular expressions and native SQL reading on Db2 LUW, IBM i and z/OS, with Db2 container rows on CI), with #16751 (Hibernate 5: rlike on Db2) and the Db2 readings of the unique constraint in #16583 (9.0.x).
Activity
Hibernate 7: pin that removing one element of a set loses the others,…
Hibernate 7: keep the 8.0.0 constructor of CollectionSecondPassBinder…
borinquenkid commentedon Oct 24, 2026
Fixed by #16750 (Hibernate 7: unique key nulls, regular expressions and native SQL reading on Db2 LUW, IBM i and z/OS, with Db2 container rows on CI), with #16751 (Hibernate 5: rlike on Db2) and the Db2 readings of the
uniqueconstraint in #16583 (9.0.x).fix(hibernate7): support Db2 in unique key null handling, regular exp…