@UniqueConstraint annotation in Table-per-class hierarchy

Description

It would be useful to be able to define a @UniqueConstraint in a subclass of a an entity with a Single Table hierarchy strategy, so that new constraints referring columns of the subclass can be added.
Right now, we can add unique constraints in the subclass only if they involve a single column (with the element 'unique' of annotation '@Column'):

pubic MySubclass extends MyEntity
{

....

@Column(name = "IDENTIFIER", length = 100, nullable = false, unique = true)
public String getIdentifier()
{
return identifier;
}

@Column(name = "PREFIX", length = 100, nullable = false)
public String getPrefix()
{
return prefix;
}

}

Being a Single Table hierarchy, @Table annotation is defined in the hierarchy superclass, and @UniqueConstraint should be all defined there.
In order to define an UniqueConstraint in the subclass, we should declare @Table annotation twice, in the sublcass too, but it has no sense and Hibernate ignores this declaration, giving the warning "[org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:602)] WARN - Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy".

@Table(name = "MY_TABLE", uniqueConstraints = @UniqueConstraint(name = "UK_MY_TABLE_1", columnNames = { "IDENTIFIER", "PREFIX" }))
pubic MySubclass extends MyEntity
{
...
}

So we can define an unique constraint in a sublcass of a single table hierarchy only if they refers a single column!

Environment

None

Assignee

Unassigned

Reporter

Leonardo Moretti

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure