Missing unique constraint for many-to-many with unique=true in list mapping

Description

You can find a description of this issue in the Hibernate forum:
https://forum.hibernate.org/viewtopic.php?f=1&t=1043611

I'll attach a test case for this in a minute.

Environment

H2Dialect (Hibernate Test Templates) on Windows 7
PostgreSQLDialect

Activity

Show:
Holger Brands
September 13, 2016, 2:05 PM

Extract the ZIP und run the testcase with mvn test.
It currently uses Hibernate 5.0.10 (see pom file, adapt for testing with other versions like 4.3.11, 5.2.2, 5.1.1).
The included HBM mapping file uses a list mapping with a many-to-many element and unique="true".

Please observe the log output for the schema generation:

While Hibernate 4.3.11 generates the following unique constraint correctly
"alter table test_workflowitem_childs add constraint UK_ojsoe2oi4ydfh13jnq8cv1k3 unique (child)"
the Hibernate 5 versions do not generate this unique constraint which is a regression I think.

Holger Brands
September 13, 2016, 2:07 PM

If it's confirmed as a bug it would be great if it could be fixed in Hibernate 5.0.x as we currently migrate a big application from 3 to 5.0.x. Thanks!

Gail Badner
September 16, 2016, 8:35 AM

Fixed in master, 5.1, and 5.0 branches.

Assignee

Andrea Boriero

Reporter

Holger Brands

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure