persistence@glassfish.java.net

Re: transient properties

From: Guy Pelletier <guy.pelletier_at_oracle.com>
Date: Fri, 29 May 2009 14:05:08 -0400

Actually this sounds like expected behavior to me.

See the following section of the spec
10.1.3.1 metadata-complete

If the metadata-complete attribute is specified on the entity element
itself, any annotations on

the entity class (and its fields and properties) are ignored. When
metadata-complete is specified

on the entity element and XML elements are omitted, the default values apply
to the given class.

Not sure which version of Glassfish you are using, but if you use
EclipseLink, it has an extended orm schema which allows you to configure the
"exclude-default-mappings" to avoid this behavior. Otherwise, yes you need
to mark the attribute as transient.

Cheers,
Guy

----- Original Message -----
From: "Mitesh Meswani" <Mitesh.Meswani_at_Sun.COM>
To: <persistence_at_glassfish.dev.java.net>
Sent: Friday, May 29, 2009 1:44 PM
Subject: Re: transient properties


> Hi Prashant,
>
> That sounds like a bug. Can you file an issue with reproducible test case.
>
> Thanks,
> Mitesh
>
> Prashant Dighe wrote:
>> Hello,
>>
>> There is an orm.xml mapping with xml-mapping-metadata-complete and access
>> specified as "PROPERTY".
>> The persistence class mapping is defined and working.
>>
>> Now when some getter is added to the persistent entity class, it gets
>> picked up and mapped by default to a column which does not exist. This
>> can be fixed using transient element in the entity definition or by
>> adding @Transient annotation to the getter.
>>
>> The question is, is there a way to prevent this w/o using transient?
>>
>> Since the meta data is complete, and is really completely defined in the
>> entity element, why is anything not defined in the attributes element of
>> the mapping being picked up?
>>
>> In other words, when the mapping is explicitly and completely defined in
>> the orm.xml, why is it trying to map other unmapped properties over
>> zealously and can this be avoided such that anything not defined in the
>> mapping should be treated as transient automatically.
>>
>> Thanks,
>> Prashant
>