jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
187 stars 55 forks source link

Clarify that @Table is disallowed on a @MappedSuperclass or @Embeddable class #586

Closed gavinking closed 3 months ago

gavinking commented 4 months ago

We have recently discovered that some users are under the misapprehension that they can use the @Table annotation of a @MappedSuperclass to define unique key constraints applying to the table mapped by each inheriting entity. This is not intended. It doesn't make sense to assign a table to a @MappedSuperclass, and so it doesn't make sense to define a constraint on its columns. An inheriting @Entity may not even have the same columns, as a result of the action of an @AttributeOverride.

We should state explicitly that the @Table annotation simply may not occur on a @MappedSuperclass or @Embeddable.