[Teneo] Annotation in ecore model (foreign key and annotation for options) [message #117272] |
Tue, 08 April 2008 13:49  |
Eclipse User |
|
|
|
Hi,
--------------------------------------------------------
1. FOREIGN_KEY Annotation:
--------------------------------------------------------
I Have the following Model.
A Class Library contains many Books. Containment Reference.
The foreignKey in the book table is library_id.
Now I would like to set an Annotation in the ecore which defines that
the Relation is a bag not a list and the foreignKey Column name is
'library_id'.
I tried the following Annotation (I tried also many more ...) but it
does not work.
<eStructuralFeatures
xsi:type="ecore:EReference"
name="books"
upperBound="-1"
eType="#//IBook"
containment="true">
<eAnnotations source="teneo.jpa">
<details
key="appinfo"
value="@OneToMany(mappedBy=library_id)"/>
</eAnnotations>
</eStructuralFeatures>
--------------------------------------------------------
2. Could I set the following Options also as Annotation?
--------------------------------------------------------
PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG
PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER
PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH
PersistenceOptions.ALWAYS_VERSION
or how could I define it for each relation
Thank you in advance
Torsten Link
|
|
|
|
|
Re: [Teneo] Annotation in ecore model (foreign key and annotation for options) [message #117393 is a reply to message #117325] |
Wed, 09 April 2008 01:11  |
Eclipse User |
|
|
|
Hi Torsten,
Yes correct, I have thought about adding a properties page which allows you to set properties for an
ecore file or a separate property file in the same directory as the ecore file but had not have time
to add this functionality.
You can also programmatically create the mapping through the HbHelper.INSTANCE.generateMapping(..)
method, so if you write a class with a main method which creates a new hbm file then you can easily
test it.
gr. Martin
Torsten Link wrote:
> Martin Taal wrote:
>
> Hi Martin,
>
> Thank you for your fast reply.
>
> The reason for setting the options as annotations is for testing only.
> When I generate the mapping file by rightclicking the ecore model it
> will not know the options which I set in the programm code.
>
>
>
>
>> Hi Torsten,
>> The following annotation will store the association as a bag (so without
>> index column): @OneToMany(indexed=false)
>> See also here:
>>
> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+non-indexed+relations
>> The following annotation will set the foreign key join column:
>> @JoinColumn(name="library_id")
>>
>> The elver.org website contains many examples of annotations, for example:
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> Regarding the options, these are all global options so I am not sure what
>> you mean set as annotations? Why would you for example set the sql escape
>> character by association?
>>
>> You can set these global options by passing them to the datastore.
>>
>> gr. Martin
>>
>> Torsten Link wrote:
>>> Hi,
>>>
>>>
>>> --------------------------------------------------------
>>> 1. FOREIGN_KEY Annotation:
>>> --------------------------------------------------------
>>>
>>> I Have the following Model.
>>>
>>> A Class Library contains many Books. Containment Reference.
>>> The foreignKey in the book table is library_id.
>>>
>>> Now I would like to set an Annotation in the ecore which defines that
>>> the Relation is a bag not a list and the foreignKey Column name is
>>> 'library_id'.
>>>
>>> I tried the following Annotation (I tried also many more ...) but it
>>> does not work.
>>> <eStructuralFeatures
>>> xsi:type="ecore:EReference"
>>> name="books"
>>> upperBound="-1"
>>> eType="#//IBook"
>>> containment="true">
>>>
>>> <eAnnotations source="teneo.jpa">
>>> <details
>>> key="appinfo"
>>> value="@OneToMany(mappedBy=library_id)"/>
>>>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>>
>>>
>>> --------------------------------------------------------
>>> 2. Could I set the following Options also as Annotation?
>>> --------------------------------------------------------
>>>
>>> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG
>>> PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER
>>> PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH
>>> PersistenceOptions.ALWAYS_VERSION
>>>
>>> or how could I define it for each relation
>>>
>>>
>>> Thank you in advance
>>>
>>> Torsten Link
>>
>
--
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] Annotation in ecore model (foreign key and annotation for options) [message #616107 is a reply to message #117272] |
Tue, 08 April 2008 14:07  |
Eclipse User |
|
|
|
Hi Torsten,
The following annotation will store the association as a bag (so without index column):
@OneToMany(indexed=false)
See also here:
http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+non-indexed+relations
The following annotation will set the foreign key join column:
@JoinColumn(name="library_id")
The elver.org website contains many examples of annotations, for example:
http://www.elver.org/hibernate/ejb3_examples.html
Regarding the options, these are all global options so I am not sure what you mean set as
annotations? Why would you for example set the sql escape character by association?
You can set these global options by passing them to the datastore.
gr. Martin
Torsten Link wrote:
> Hi,
>
>
> --------------------------------------------------------
> 1. FOREIGN_KEY Annotation:
> --------------------------------------------------------
>
> I Have the following Model.
>
> A Class Library contains many Books. Containment Reference.
> The foreignKey in the book table is library_id.
>
> Now I would like to set an Annotation in the ecore which defines that
> the Relation is a bag not a list and the foreignKey Column name is
> 'library_id'.
>
> I tried the following Annotation (I tried also many more ...) but it
> does not work.
> <eStructuralFeatures
> xsi:type="ecore:EReference"
> name="books"
> upperBound="-1"
> eType="#//IBook"
> containment="true">
>
> <eAnnotations source="teneo.jpa">
> <details
> key="appinfo"
> value="@OneToMany(mappedBy=library_id)"/>
>
> </eAnnotations>
> </eStructuralFeatures>
>
>
>
> --------------------------------------------------------
> 2. Could I set the following Options also as Annotation?
> --------------------------------------------------------
>
> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG
> PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER
> PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH
> PersistenceOptions.ALWAYS_VERSION
>
> or how could I define it for each relation
>
>
> Thank you in advance
>
> Torsten Link
--
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] Annotation in ecore model (foreign key and annotation for options) [message #616114 is a reply to message #117285] |
Tue, 08 April 2008 18:07  |
Eclipse User |
|
|
|
Martin Taal wrote:
Hi Martin,
Thank you for your fast reply.
The reason for setting the options as annotations is for testing only.
When I generate the mapping file by rightclicking the ecore model it
will not know the options which I set in the programm code.
> Hi Torsten,
> The following annotation will store the association as a bag (so without
> index column): @OneToMany(indexed=false)
> See also here:
>
http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+non-indexed+relations
>
> The following annotation will set the foreign key join column:
> @JoinColumn(name="library_id")
>
> The elver.org website contains many examples of annotations, for example:
> http://www.elver.org/hibernate/ejb3_examples.html
>
> Regarding the options, these are all global options so I am not sure what
> you mean set as annotations? Why would you for example set the sql escape
> character by association?
>
> You can set these global options by passing them to the datastore.
>
> gr. Martin
>
> Torsten Link wrote:
>> Hi,
>>
>>
>> --------------------------------------------------------
>> 1. FOREIGN_KEY Annotation:
>> --------------------------------------------------------
>>
>> I Have the following Model.
>>
>> A Class Library contains many Books. Containment Reference.
>> The foreignKey in the book table is library_id.
>>
>> Now I would like to set an Annotation in the ecore which defines that
>> the Relation is a bag not a list and the foreignKey Column name is
>> 'library_id'.
>>
>> I tried the following Annotation (I tried also many more ...) but it
>> does not work.
>> <eStructuralFeatures
>> xsi:type="ecore:EReference"
>> name="books"
>> upperBound="-1"
>> eType="#//IBook"
>> containment="true">
>>
>> <eAnnotations source="teneo.jpa">
>> <details
>> key="appinfo"
>> value="@OneToMany(mappedBy=library_id)"/>
>>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>>
>>
>> --------------------------------------------------------
>> 2. Could I set the following Options also as Annotation?
>> --------------------------------------------------------
>>
>> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG
>> PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER
>> PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH
>> PersistenceOptions.ALWAYS_VERSION
>>
>> or how could I define it for each relation
>>
>>
>> Thank you in advance
>>
>> Torsten Link
>
>
|
|
|
Re: [Teneo] Annotation in ecore model (foreign key and annotation for options) [message #616129 is a reply to message #117325] |
Wed, 09 April 2008 01:11  |
Eclipse User |
|
|
|
Hi Torsten,
Yes correct, I have thought about adding a properties page which allows you to set properties for an
ecore file or a separate property file in the same directory as the ecore file but had not have time
to add this functionality.
You can also programmatically create the mapping through the HbHelper.INSTANCE.generateMapping(..)
method, so if you write a class with a main method which creates a new hbm file then you can easily
test it.
gr. Martin
Torsten Link wrote:
> Martin Taal wrote:
>
> Hi Martin,
>
> Thank you for your fast reply.
>
> The reason for setting the options as annotations is for testing only.
> When I generate the mapping file by rightclicking the ecore model it
> will not know the options which I set in the programm code.
>
>
>
>
>> Hi Torsten,
>> The following annotation will store the association as a bag (so without
>> index column): @OneToMany(indexed=false)
>> See also here:
>>
> http://www.elver.org/hibernate/hibernate_relations.html#Mapp ing+non-indexed+relations
>> The following annotation will set the foreign key join column:
>> @JoinColumn(name="library_id")
>>
>> The elver.org website contains many examples of annotations, for example:
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> Regarding the options, these are all global options so I am not sure what
>> you mean set as annotations? Why would you for example set the sql escape
>> character by association?
>>
>> You can set these global options by passing them to the datastore.
>>
>> gr. Martin
>>
>> Torsten Link wrote:
>>> Hi,
>>>
>>>
>>> --------------------------------------------------------
>>> 1. FOREIGN_KEY Annotation:
>>> --------------------------------------------------------
>>>
>>> I Have the following Model.
>>>
>>> A Class Library contains many Books. Containment Reference.
>>> The foreignKey in the book table is library_id.
>>>
>>> Now I would like to set an Annotation in the ecore which defines that
>>> the Relation is a bag not a list and the foreignKey Column name is
>>> 'library_id'.
>>>
>>> I tried the following Annotation (I tried also many more ...) but it
>>> does not work.
>>> <eStructuralFeatures
>>> xsi:type="ecore:EReference"
>>> name="books"
>>> upperBound="-1"
>>> eType="#//IBook"
>>> containment="true">
>>>
>>> <eAnnotations source="teneo.jpa">
>>> <details
>>> key="appinfo"
>>> value="@OneToMany(mappedBy=library_id)"/>
>>>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>>
>>>
>>> --------------------------------------------------------
>>> 2. Could I set the following Options also as Annotation?
>>> --------------------------------------------------------
>>>
>>> PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG
>>> PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER
>>> PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH
>>> PersistenceOptions.ALWAYS_VERSION
>>>
>>> or how could I define it for each relation
>>>
>>>
>>> Thank you in advance
>>>
>>> Torsten Link
>>
>
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.02790 seconds