|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
transient propertiesHello,
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 |
|
|
Re: transient propertiesHi 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 |
|
|
Re: transient propertiesActually 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@...> To: <persistence@...> 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 > |
|
|
Re: transient propertiesThanks Guy and Mitesh.
Now it dawns upon me that this may perhaps have to do with entity manager and since I am using spring, I will rather go and bug the spring forum :) But since this is being logged by TopLink, do you think it has anything to do with TopLink or just the entity manager? Most likely the later but just checking.... [TopLink Config]: 2009.05.29 08:47:05.688--ServerSession(1498809964)--Thread(Thread[main,5,main])--The column name for element [public com.example.blah.getFoo() ] is being defaulted to: FOO. Prashant Guy Pelletier wrote: > 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@...> > To: <persistence@...> > 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 >> > |
|
|
Re: transient propertiesI can say with 100% certainty it's definitely TopLink.
Cheers, Guy ----- Original Message ----- From: "Prashant Dighe" <Prashant.Dighe@...> To: <persistence@...> Sent: Friday, May 29, 2009 2:21 PM Subject: Re: transient properties > Thanks Guy and Mitesh. > > Now it dawns upon me that this may perhaps have to do with entity manager > and since I am using spring, I will rather go and bug the spring forum :) > > But since this is being logged by TopLink, do you think it has anything to > do with TopLink or just the entity manager? Most likely the later but just > checking.... > > [TopLink Config]: 2009.05.29 > 08:47:05.688--ServerSession(1498809964)--Thread(Thread[main,5,main])--The > column name for element [public com.example.blah.getFoo() ] is being > defaulted to: FOO. > > Prashant > > Guy Pelletier wrote: >> 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@...> >> To: <persistence@...> >> 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 >>> >> > > |
|
|
Re: transient propertiesPrashant,
Do you explicitly list all defined properties in the orm.xml or just specify the access type? If it's the former, and an extra getter is treated as a property, it looks like a bug. Otherwise listing all the persistent properties can be a solution for you. Regards, -marina 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 |
|
|
Re: transient propertiesPrashant,
Does the getter have an equivalent setter? If so, this is not a bug. This is the defaulting behavior I outlined earlier. If there is no setter than, this is a bug. Cheers, Guy ----- Original Message ----- From: "Marina Vatkina" <Marina.Vatkina@...> To: <persistence@...> Sent: Friday, May 29, 2009 2:57 PM Subject: Re: transient properties > Prashant, > > Do you explicitly list all defined properties in the orm.xml or just > specify the access type? If it's the former, and an extra getter is > treated as a property, it looks like a bug. Otherwise listing all the > persistent properties can be a solution for you. > > Regards, > -marina > > 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 > > |
|
|
Re: transient propertiesMarina Vatkina wrote:
> Prashant, > > Do you explicitly list all defined properties in the orm.xml Yes. > or just specify the access type? If it's the former, and an extra > getter is treated as a property, it looks like a bug. Otherwise > listing all the persistent properties can be a solution for you. > > Regards, > -marina > > 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 > |
|
|
Re: transient propertiesYes, only the ones with gettter AND setter are auto mapped.
The ones with only a getter is not mapped. Since I can not use provider extensions because I have no control over what the customer may use, it seems that, unfortunately, I will have to go with explicit transient definition. I would interpret "xml-mapping-metadata-complete" as an indication to the provider that this is it. Whatever is there in xml is what you are supposed to deal with. Look no further. Anyhow, if this is not the right interpretation then I feel the spec should rather handle this in the next version, like folding the extensions into the spec. Thanks, Prashant Guy Pelletier wrote: > Prashant, > > Does the getter have an equivalent setter? If so, this is not a bug. > This is the defaulting behavior I outlined earlier. > > If there is no setter than, this is a bug. > > Cheers, > Guy > > ----- Original Message ----- From: "Marina Vatkina" > <Marina.Vatkina@...> > To: <persistence@...> > Sent: Friday, May 29, 2009 2:57 PM > Subject: Re: transient properties > > >> Prashant, >> >> Do you explicitly list all defined properties in the orm.xml or just >> specify the access type? If it's the former, and an extra getter is >> treated as a property, it looks like a bug. Otherwise listing all the >> persistent properties can be a solution for you. >> >> Regards, >> -marina >> >> 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 >> >> > |
| Free embeddable forum powered by Nabble | Forum Help |