[hibernate-dev] Natural ids and inheritance
John Verhaeg
jverhaeg at redhat.com
Tue Feb 28 14:28:15 EST 2012
I probably don't understand the complexities with this, but wouldn't the ID values in AA have to be completely independent of the values in A?
> On 28 févr. 2012, at 17:59, Steve Ebersole wrote:
>
>> Another discrepancy between hbm.xml and annotations currently is the
>> definition of natural ids. hbm.xml only allows natural ids to be
>> defined on the root entity, annotations allow it to be defined on any
>> level of the hierarchy, even across classes.
>>
>> We need to decide what we want to support. 2 things to consider here are:
>> 1) whether we limit @NaturalId to only root entity meta (and maybe
>> @MappedSuperclass for root entities)
>> 2) if we do not limit, what @NaturalId spread across a hierarchy "means"
>>
>> In the second point, consider:
>> class A
>> @NaturalId
>> key1
>>
>> class AA extends A
>> @NaturalId
>> key2
>>
>> Personally I vote for limiting @NaturalId to the root entity. This
>> allows caching to work just like it does for identifiers.
JPAV
More information about the hibernate-dev
mailing list