Ok, so from your answer, I take it that it is the implementation's
responsibility to walk up the entity's metadata hierarchy through any
mapped superclasses until the class defining the identity is found.
Is that specified? The spec currently says:
/**
* Return the attribute that corresponds to the id attribute of
* the entity or mapped superclass.
* @param type the type of the represented id attribute
* @return id attribute
* @throws IllegalArgumentException if id attribute of the given
* type is not present in the identifiable type or if
* the identifiable type has an id class
*/
<Y> SingularAttribute<? super X, Y> getId(Class<Y> type);
Potential javadoc clarification:
"Return the attribute that corresponds to the id attribute of the entity,
mapped superclass, or the id of the entity's or mapped superclasses'
superclass(es). This method must not return null."
Better? Is there a TCK test for this?
-matthew
On Mon, Jul 23, 2012 at 11:05 AM, Linda DeMichiel <
linda.demichiel_at_oracle.com> wrote:
> Hi Matthew,
>
>
> On 7/23/2012 6:44 AM, Matthew Adams wrote:
>
>> Hi all,
>>
>> Scenario: entity "app.domain.Profile" extends abstract mapped superclass
>> "app.domain.AbstractEntity". If
>> AbstractEntity defines a single string field as its @Id, should the
>> IdentifiableType instance corresponding to
>> app.domain.Profile guarantee that its getId(Class) method will never
>> return null?
>>
>> In other words, is it up to the client of the JPA metamodel to go up the
>> entity's type hierarchy until it finds the
>> SingularAttribute for the id field, or should the JPA implementation do
>> that?
>>
>>
> I'm not sure I understand your question fully. However, it is the
> responsibility of the metamodel implementation
> to return the SingularAttribute that is the value of getId (this may
> involve traversing the hierarchy if getId
> were not defined in the IdentifiablyType itself).
>
> -Linda
>
>
> Thanks,
>> Matthew
>>
>> --
>> mailto:matthew_at_matthewadams.me
>> skype:matthewadams12
>> googletalk:matthew@**matthewadams.me<googletalk%3Amatthew_at_matthewadams.me><mailto:
>> googletalk%3Amatthew@**matthewadams.me<googletalk%253Amatthew_at_matthewadams.me>
>> >
>> http://matthewadams.me
>> http://www.linkedin.com/in/**matthewadams<http://www.linkedin.com/in/matthewadams>
>>
>>
--
mailto:matthew_at_matthewadams.me <matthew_at_matthewadams.me>
skype:matthewadams12
googletalk:matthew_at_matthewadams.me
http://matthewadams.me
http://www.linkedin.com/in/matthewadams