Uploaded image for project: 'Hibernate ORM'
  1. HHH-8026

Duplicate constraint names with unique=true


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.10
    • Fix Version/s: 4.2.0.CR2, 4.1.11, 4.3.0.Beta1
    • Component/s: None
    • Labels:
    • Environment:
      windows xp, java 1.6.0_41, hsqldb 2.2.9, oracle 11g, mssql 2008R2
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
    • Sprint:


      The fix for HHH-7797 Closed 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'.




            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: