persistence@glassfish.java.net

Re: single access type for entire hierarchy?

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Thu, 16 Feb 2006 09:53:20 +0530

Hi Mike,

I know you mentioned in another email that you and Linda would discuss
this further and get back. But here are a few more that you want to
clarify as well...
Mike Keith wrote:

>Is Linda not on the persistence mailing list?
>
>Sahoo, this comment in the spec was there primarily for the
>annotations case.
>
How does a reader know whether certain things are exclusively for
annotations? Chapter #1 of the spec has a blanket statement:

/This document is written in terms of the use of Java language meta data
annotations to specify the
semantics of persistent classes and their object/relational mapping. An
XML descriptor (as specified in
Chapter 10) may be used as an alternative to annotations or to augment
or override annotations. The
elements of this descriptor mirror the annotations and have the same
semantics.
/

>We will try to add some language that makes
>it clearer, but there is no reason why you wouldn't be able to
>set different access types for different entities in XML.
>
>The question that I expected you to ask is the part that we
>have not specified in the spec yet, which is what happens
>when access is set on an entity that is not metadata complete
>(ie annotations may have been processed on it).
>
>
>
A very good question, indeed.

>We will add a section to describe how access works,
>but essentially it applies to all of the mappings defined
>in XML.
>
With above rule, a class can have mixed access type, right? e.g.
@Entity
class A {
@Basic int i;
int id;
String name;
int getId(){...}
void setId(int i){...}
}

orm.xml:
<entity-mappings>
<entity class="A" access="PROPERTY">
<attributes>
<id name="id"/>
</attributes>
</entity>
</entity-mappings>

> If metadata-complete attribute is set then that access
>type will also be applied to the default mappings that get added.
>
>
>
I hope we will not end up with very complex rules! IMHO, *partial*
overriding of object model in XML should be disallowed.

Any way, I will wait after EG takes a final decision on this subject.

Thanks & regards,
Sahoo

>-Mike
>
>
>
>>-----Original Message-----
>>From: Marina Vatkina [mailto:Marina.Vatkina_at_Sun.COM]
>>Sent: Wednesday, February 15, 2006 3:41 PM
>>To: persistence_at_glassfish.dev.java.net
>>Cc: Michael Keith; Linda Demichiel
>>Subject: Re: single access type for entire hierarchy?
>>
>>
>>Adding Linda to the thread.
>>
>>-marina
>>
>>Sanjeeb Kumar Sahoo wrote On 02/15/06 10:22,:
>>
>>
>>>Hi Mike,
>>>
>>>Michael Keith wrote:
>>>
>>>
>>>
>>>
>>>>No, you can specify different access types in the XML mapping file.
>>>>
>>>>
>>>>
>>>>
>>>Thanks for responding. Now I see a small confusion for
>>>
>>>
>>users here: what
>>
>>
>>>is the access type for class Derived in the following example? Is it
>>>PROPERTY because the Base class uses PROPERTY access or is it FIELD
>>>because the mapping file level default is FIELD?
>>>
>>>(Note: the XML fragment might not comply with orm schema, it is just
>>>used as example)
>>><entity-mappings>
>>> <!-- mapping file level default is FIELD access-->
>>> <access>FIELD</access>
>>> <entity class="Base" access="PROPERTY">
>>> <entity>
>>> <entity class="Derived"> <!-- Derived extends Base -->
>>> <entity>
>>></entity-mappings>
>>>
>>>Reading the spec, I don't find a clear cut answer. So my worry is do
>>>have such tests in CTS to ensure portability of applications?
>>>
>>>Thanks,
>>>Sahoo
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>
>>>>
>>>>>From Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
>>>
>>>
>>>
>>>>Sent Wed 2/15/2006 5:46 AM
>>>>To persistence_at_glassfish.dev.java.net
>>>>
>>>>
>><persistence_at_glassfish.dev.java.net>; Mike Keith
>><michael.keith_at_oracle.com>
>>
>>
>>>>Subject single access type for entire hierarchy?
>>>>
>>>>Hi,
>>>>
>>>>[Section 2.1.1]
>>>>/A single access type (field or property access) applies to
>>>>
>>>>
>>an entity
>>
>>
>>>>hierarchy./
>>>>
>>>>Is this rule applicable even when access type is specified on a per
>>>>class basis using orm.xml file?
>>>>
>>>>Thanks,
>>>>Sahoo
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>
>
>