We're updating the issue view to help you get more done. 

Duplicate constraint names with unique=true

Description

The fix for changed the way unique constraints are generated. Unfortunately, if 'unique=true' is used in a property in the mapping, duplicate constraint names may be generated, which is not supported by most databases (tested with hsqldb 2.2.9, oracle 11g and mssql 2008R2).

I've created a junit test that works fine with hibernate-core 4.1.9 but fails with 4.1.10. You'll see error messages in the log when constraints are created and the ConstraintViolationException will not be thrown when creating the second object (although it should be thrown).

As far as I've seen there was nothing wrong with the way hibernate 4.1.9 (and also 4.1.7 and earlier) generated unique constraints. So unless there's an actual problem (other than code esthetics) that I'm not aware of, I'd suggest to revert those changes.

As a workaround, it is possible to use 'unique-key=<uniqueConstraintName>' instead of 'unique=true'.

Environment

windows xp, java 1.6.0_41, hsqldb 2.2.9, oracle 11g, mssql 2008R2

Status

Assignee

Brett Meyer

Reporter

Barney

Fix versions

Affects versions

4.1.10

Priority

Major