Changing @ManyToMany <-> @OneToMany doesn't add/remove unique constraint

Description

When having a @OneToMany annotation on an entity and later changing that to @ManyToMany, Hibernate does not drop the unique constraint. It simply leaves the constraint intact.

Dropping and letting Hibernate regenerate the table does not add the unique constraint (works as expected). This means you'll not be able to insert multiple entries in the table, unless you regenerate it.

Created Table thus far:

Likewise, changing @ManyToMany to @OneToMany will add a unique constraint. Inserting multiple values will however work fine.

Re-generating the table will add the constraint just fine.

SQL thus far:

Attached are the pretty basic entities I've used to confirm this behaviour.

Environment

Hibernate 4.1.1, bundled with JBoss AS 7.1.1
Microsoft SQL Server 2008

Status

Assignee

Unassigned

Reporter

Marcus Bauer

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure