Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Annotation in ecore model (foreign key and annotation for options)
[Teneo] Annotation in ecore model (foreign key and annotation for options) [message #117272] Tue, 08 April 2008 17:49 Go to next message
Torsten Link is currently offline Torsten LinkFriend
Messages: 51
Registered: July 2009
Member
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 #117285 is a reply to message #117272] Tue, 08 April 2008 18:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 #117325 is a reply to message #117285] Tue, 08 April 2008 22:07 Go to previous messageGo to next message
Torsten Link is currently offline Torsten LinkFriend
Messages: 51
Registered: July 2009
Member
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 #117393 is a reply to message #117325] Wed, 09 April 2008 05:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 18:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 22:07 Go to previous message
Torsten Link is currently offline Torsten LinkFriend
Messages: 51
Registered: July 2009
Member
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 05:11 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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
Previous Topic:Multi-database Teneo
Next Topic:Multi-database Teneo
Goto Forum:
  


Current Time: Mon Jun 14 22:50:04 GMT 2021

Powered by FUDForum. Page generated in 0.07336 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top