Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Setting Id generator from ecore file
[Teneo] Setting Id generator from ecore file [message #65217] |
Wed, 20 December 2006 18:08  |
Eclipse User |
|
|
|
Originally posted by: g.idema.zonnet.nl
Before I switched to the latest Teneo build, I used the following annotation
on my ID attributes to set the generator in the hibernate mapping:
<eAnnotations source="http://hibernate.elver.org/GeneratedValue">
<details key="strategy" value="AUTO"/>
</eAnnotations>
In the latest build, I don't get the <generator> element in the hibenate
mapping anymore.
Any suggestions as for what I'm doing wrong?
Gertjan Idema
|
|
| |
Re: [Teneo] Setting Id generator from ecore file [message #65362 is a reply to message #65259] |
Thu, 21 December 2006 10:14   |
Eclipse User |
|
|
|
Originally posted by: g.idema.zonnet.nl
Hi Martin,
Thanks. I changed the annotation to the following and it work as expected:
<eAnnotations source="teneo.jpa/Id">
<details key="appinfo" value="@GeneratedValue(strategy="AUTO")"/ >
</eAnnotations>
However if I attach this annotation to an EDataType and use this for the id
attributes in all of my classes, this only work for the first class in the
package. For example, if I have two classes Foo, Bar in my package, both
with an id attribute of EDataType ID, where ID is annotated as shown above.
Then when I create the hibernate mapping, only class Foo gets the <generator
class="native"/> element.
Switching the order of the classes in the package to Bar, Foo results in
only class Bar having the <generator class="native"/> element instead.
I decided to dig into this issue and found the following:
The GeneratedValue attribute is contained in the HbAnnotatedEDataType Class,
as are the other annotation attributes.
Therefore the first call to "pea.eSet(asf, ped.eGet(esf));" in the
PersistenceMappingBuilder removes the value from the HbAnnotatedEDataType
instance, preventing it from being copied the next time.
I suggest the following fix:
replace "pea.eSet(asf, ped.eGet(esf));" with "pea.eSet(asf,
EcoreUtil.copy(ped.eGet(esf)));"
Gertjan Idema
"Martin Taal" <mtaal@elver.org> wrote in message
news:emd30s$fk9$1@utils.eclipse.org...
> The source of the annotation changed a few months ago:
> http://www.elver.org/hibernate/ejb3_format.html
>
> gr. Martin
>
> Gertjan Idema wrote:
>> Before I switched to the latest Teneo build, I used the following
>> annotation on my ID attributes to set the generator in the hibernate
>> mapping:
>>
>> <eAnnotations source="http://hibernate.elver.org/GeneratedValue">
>>
>> <details key="strategy" value="AUTO"/>
>>
>> </eAnnotations>
>>
>> In the latest build, I don't get the <generator> element in the hibenate
>> mapping anymore.
>>
>> Any suggestions as for what I'm doing wrong?
>>
>> Gertjan Idema
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Setting Id generator from ecore file [message #65405 is a reply to message #65362] |
Thu, 21 December 2006 10:47  |
Eclipse User |
|
|
|
Thanks GertJan for researching the cause of this.
I committed a solution similar to your proposal.
gr. Martin
Gertjan Idema wrote:
> Hi Martin,
>
> Thanks. I changed the annotation to the following and it work as expected:
>
> <eAnnotations source="teneo.jpa/Id">
> <details key="appinfo" value="@GeneratedValue(strategy="AUTO")"/ >
> </eAnnotations>
>
> However if I attach this annotation to an EDataType and use this for the id
> attributes in all of my classes, this only work for the first class in the
> package. For example, if I have two classes Foo, Bar in my package, both
> with an id attribute of EDataType ID, where ID is annotated as shown above.
> Then when I create the hibernate mapping, only class Foo gets the <generator
> class="native"/> element.
> Switching the order of the classes in the package to Bar, Foo results in
> only class Bar having the <generator class="native"/> element instead.
>
> I decided to dig into this issue and found the following:
> The GeneratedValue attribute is contained in the HbAnnotatedEDataType Class,
> as are the other annotation attributes.
> Therefore the first call to "pea.eSet(asf, ped.eGet(esf));" in the
> PersistenceMappingBuilder removes the value from the HbAnnotatedEDataType
> instance, preventing it from being copied the next time.
>
> I suggest the following fix:
>
> replace "pea.eSet(asf, ped.eGet(esf));" with "pea.eSet(asf,
> EcoreUtil.copy(ped.eGet(esf)));"
>
> Gertjan Idema
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:emd30s$fk9$1@utils.eclipse.org...
>> The source of the annotation changed a few months ago:
>> http://www.elver.org/hibernate/ejb3_format.html
>>
>> gr. Martin
>>
>> Gertjan Idema wrote:
>>> Before I switched to the latest Teneo build, I used the following
>>> annotation on my ID attributes to set the generator in the hibernate
>>> mapping:
>>>
>>> <eAnnotations source="http://hibernate.elver.org/GeneratedValue">
>>>
>>> <details key="strategy" value="AUTO"/>
>>>
>>> </eAnnotations>
>>>
>>> In the latest build, I don't get the <generator> element in the hibenate
>>> mapping anymore.
>>>
>>> Any suggestions as for what I'm doing wrong?
>>>
>>> Gertjan Idema
>>>
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: [Teneo] Setting Id generator from ecore file [message #597312 is a reply to message #65259] |
Thu, 21 December 2006 10:14  |
Eclipse User |
|
|
|
Originally posted by: g.idema.zonnet.nl
Hi Martin,
Thanks. I changed the annotation to the following and it work as expected:
<eAnnotations source="teneo.jpa/Id">
<details key="appinfo" value="@GeneratedValue(strategy="AUTO")"/ >
</eAnnotations>
However if I attach this annotation to an EDataType and use this for the id
attributes in all of my classes, this only work for the first class in the
package. For example, if I have two classes Foo, Bar in my package, both
with an id attribute of EDataType ID, where ID is annotated as shown above.
Then when I create the hibernate mapping, only class Foo gets the <generator
class="native"/> element.
Switching the order of the classes in the package to Bar, Foo results in
only class Bar having the <generator class="native"/> element instead.
I decided to dig into this issue and found the following:
The GeneratedValue attribute is contained in the HbAnnotatedEDataType Class,
as are the other annotation attributes.
Therefore the first call to "pea.eSet(asf, ped.eGet(esf));" in the
PersistenceMappingBuilder removes the value from the HbAnnotatedEDataType
instance, preventing it from being copied the next time.
I suggest the following fix:
replace "pea.eSet(asf, ped.eGet(esf));" with "pea.eSet(asf,
EcoreUtil.copy(ped.eGet(esf)));"
Gertjan Idema
"Martin Taal" <mtaal@elver.org> wrote in message
news:emd30s$fk9$1@utils.eclipse.org...
> The source of the annotation changed a few months ago:
> http://www.elver.org/hibernate/ejb3_format.html
>
> gr. Martin
>
> Gertjan Idema wrote:
>> Before I switched to the latest Teneo build, I used the following
>> annotation on my ID attributes to set the generator in the hibernate
>> mapping:
>>
>> <eAnnotations source="http://hibernate.elver.org/GeneratedValue">
>>
>> <details key="strategy" value="AUTO"/>
>>
>> </eAnnotations>
>>
>> In the latest build, I don't get the <generator> element in the hibenate
>> mapping anymore.
>>
>> Any suggestions as for what I'm doing wrong?
>>
>> Gertjan Idema
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Setting Id generator from ecore file [message #600185 is a reply to message #65362] |
Thu, 21 December 2006 10:47  |
Eclipse User |
|
|
|
Thanks GertJan for researching the cause of this.
I committed a solution similar to your proposal.
gr. Martin
Gertjan Idema wrote:
> Hi Martin,
>
> Thanks. I changed the annotation to the following and it work as expected:
>
> <eAnnotations source="teneo.jpa/Id">
> <details key="appinfo" value="@GeneratedValue(strategy="AUTO")"/ >
> </eAnnotations>
>
> However if I attach this annotation to an EDataType and use this for the id
> attributes in all of my classes, this only work for the first class in the
> package. For example, if I have two classes Foo, Bar in my package, both
> with an id attribute of EDataType ID, where ID is annotated as shown above.
> Then when I create the hibernate mapping, only class Foo gets the <generator
> class="native"/> element.
> Switching the order of the classes in the package to Bar, Foo results in
> only class Bar having the <generator class="native"/> element instead.
>
> I decided to dig into this issue and found the following:
> The GeneratedValue attribute is contained in the HbAnnotatedEDataType Class,
> as are the other annotation attributes.
> Therefore the first call to "pea.eSet(asf, ped.eGet(esf));" in the
> PersistenceMappingBuilder removes the value from the HbAnnotatedEDataType
> instance, preventing it from being copied the next time.
>
> I suggest the following fix:
>
> replace "pea.eSet(asf, ped.eGet(esf));" with "pea.eSet(asf,
> EcoreUtil.copy(ped.eGet(esf)));"
>
> Gertjan Idema
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:emd30s$fk9$1@utils.eclipse.org...
>> The source of the annotation changed a few months ago:
>> http://www.elver.org/hibernate/ejb3_format.html
>>
>> gr. Martin
>>
>> Gertjan Idema wrote:
>>> Before I switched to the latest Teneo build, I used the following
>>> annotation on my ID attributes to set the generator in the hibernate
>>> mapping:
>>>
>>> <eAnnotations source="http://hibernate.elver.org/GeneratedValue">
>>>
>>> <details key="strategy" value="AUTO"/>
>>>
>>> </eAnnotations>
>>>
>>> In the latest build, I don't get the <generator> element in the hibenate
>>> mapping anymore.
>>>
>>> Any suggestions as for what I'm doing wrong?
>>>
>>> Gertjan Idema
>>>
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Sat May 24 09:40:03 EDT 2025
Powered by FUDForum. Page generated in 0.04888 seconds
|