JohannesMartin (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMDcxYzUyNTdi...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15529?atlOrigin=eyJpIjoiMDcxYz...
) HHH-15529 (
https://hibernate.atlassian.net/browse/HHH-15529?atlOrigin=eyJpIjoiMDcxYz...
) Cannot override non-identifier propety from @MappedSuperclass and make it identifier in
subclass (
https://hibernate.atlassian.net/browse/HHH-15529?atlOrigin=eyJpIjoiMDcxYz...
)
Change By: JohannesMartin (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
I’ve got a @MappedSuperClass A defining field testA as non-identifier. Class B extends
Class A, defining additional field testB. Class B annotates both field testA and field
testB with @Id.
At runtime, hibernate 5.6.11 complains:
org.hibernate.MappingException: You cannot override the \[testA] non-identifier property
from the \[sample.entities.A] base class or @MappedSuperclass and make it an identifier in
the \[sample.entities.B] subclass\!
Earlier versions just silently ignore the @Id annotation on testA.
If I annotate testA as @Id in the MappedSuperclass, the code runs fine, but this violates
JPA spec (JPA 2.1
[
http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec|http:...
Chapter 2.4):
{quote}The primary key must be defined on the entity class that is the root of the entity
hierarchy or on a mapped superclass that is a (direct or indirect) superclass of all
entity classes in the entity hierarchy. The primary key must be defined exactly once in an
entity hierarchy.{quote}
Why does hibernate handle things like this? Is there a way around it. ?
(
https://hibernate.atlassian.net/browse/HHH-15529#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15529#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )