Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: modelling associations
Re: modelling associations [message #427595] Mon, 23 February 2009 22:00 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi RJ,
There is no more detailed article available then what is available on elver.org or the hibernate manual (or posts on the
newsgroup).

In this case there is a many-to-many present in the mapping, but it has the special attribute unique="true", which means
it is in fact a one-to-many. A OneToMany annotation can still be mapped with a many-to-many in hbm (as long as it has
unique="true"). See these parts of the hibernate manual:
http://www.hibernate.org/hib_docs/reference/en/html/assoc-un idirectional-join.html
http://www.hibernate.org/hib_docs/reference/en/html/assoc-bi directional-join.html

Note that support for Teneo is given on the EMF newsgroup which I cc-ed.

gr. Martin

RJDAG wrote:
> Hello
>
> I am new to Teneo and Emf.
> The modeling associations article on the elever website did give me some
> overview. (http://www.elver.org/hibernate/hibernate_relations.html) But Is
> there a more detailed article available anywhere?
>
> I am working with the library example
> I am trying to map the Writer to books relationshp as OneToMany
> relationship.
> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
> upperBound="-1"
>
> eType="#//Book" eOpposite="#//Book/author">
>
> <eAnnotations source="teneo.jpa">
>
> <details key="appinfo" value="@OneToMany(mappedBy=&quot;author&quot;,
> indexed=false)"/>
>
> </eAnnotations>
>
> </eStructuralFeatures>
>
> But the mapping generated is always of type many-to-many.
>
> What am I doing wrong?
>
> Thanks
> RJ
>
>
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: modelling associations [message #427600 is a reply to message #427595] Tue, 24 February 2009 00:10 Go to previous messageGo to next message
Rachna Bakhru is currently offline Rachna BakhruFriend
Messages: 45
Registered: July 2009
Member
Thank you for the quick response.

I found the cascadenotall example on the elver website:
http://www.elver.org/hibernate/ejb3_examples.html

I wish to generate an hbm like
CascadeNotallAction_mysql_a_o_hibernate.hbm.xml but when i generate it
I get hibernate.hbm.xml.

I do not want to use the write_books table to store theWriter to books
relationship.

Thanks
RJ

"Martin Taal" <mtaal@elver.org> wrote in message
news:gnv6a3$7ld$1@build.eclipse.org...
> Hi RJ,
> There is no more detailed article available then what is available on
> elver.org or the hibernate manual (or posts on the
> newsgroup).
>
> In this case there is a many-to-many present in the mapping, but it has
> the special attribute unique="true", which means
> it is in fact a one-to-many. A OneToMany annotation can still be mapped
> with a many-to-many in hbm (as long as it has
> unique="true"). See these parts of the hibernate manual:
> http://www.hibernate.org/hib_docs/reference/en/html/assoc-un idirectional-join.html
> http://www.hibernate.org/hib_docs/reference/en/html/assoc-bi directional-join.html
>
> Note that support for Teneo is given on the EMF newsgroup which I cc-ed.
>
> gr. Martin
>
> RJDAG wrote:
>> Hello
>>
>> I am new to Teneo and Emf.
>> The modeling associations article on the elever website did give me some
>> overview. (http://www.elver.org/hibernate/hibernate_relations.html) But
>> Is
>> there a more detailed article available anywhere?
>>
>> I am working with the library example
>> I am trying to map the Writer to books relationshp as OneToMany
>> relationship.
>> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
>> upperBound="-1"
>>
>> eType="#//Book" eOpposite="#//Book/author">
>>
>> <eAnnotations source="teneo.jpa">
>>
>> <details key="appinfo" value="@OneToMany(mappedBy=&quot;author&quot;,
>> indexed=false)"/>
>>
>> </eAnnotations>
>>
>> </eStructuralFeatures>
>>
>> But the mapping generated is always of type many-to-many.
>>
>> What am I doing wrong?
>>
>> Thanks
>> RJ
>>
>>
>>
>>
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Cell: +31 (0)6 288 48 943
> 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: modelling associations [message #427601 is a reply to message #427600] Tue, 24 February 2009 05:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi RJ,
As a default Teneo will use join tables for non-containment relations. You can disable this by setting this persistence
option to false:
PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_ASSOCIATIONS

When this option is false then you can set a join table for a an association by setting the @JoinTable annotation.

As you are new to EMF, a containment relation is a parent-child relation whereby the child depends on the parent for its
existence. In the library example, a writer and book are contained in a library. The writer and book relationship in
this model is non-containment.

The reason that Teneo (as a default) uses join tables for non-containment relations is that this is safer (less change
on name clashes) when having very complex models with multiple inheritance.

gr. Martin

RJDAG wrote:
> Thank you for the quick response.
>
> I found the cascadenotall example on the elver website:
> http://www.elver.org/hibernate/ejb3_examples.html
>
> I wish to generate an hbm like
> CascadeNotallAction_mysql_a_o_hibernate.hbm.xml but when i generate it
> I get hibernate.hbm.xml.
>
> I do not want to use the write_books table to store theWriter to books
> relationship.
>
> Thanks
> RJ
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:gnv6a3$7ld$1@build.eclipse.org...
>> Hi RJ,
>> There is no more detailed article available then what is available on
>> elver.org or the hibernate manual (or posts on the
>> newsgroup).
>>
>> In this case there is a many-to-many present in the mapping, but it has
>> the special attribute unique="true", which means
>> it is in fact a one-to-many. A OneToMany annotation can still be mapped
>> with a many-to-many in hbm (as long as it has
>> unique="true"). See these parts of the hibernate manual:
>> http://www.hibernate.org/hib_docs/reference/en/html/assoc-un idirectional-join.html
>> http://www.hibernate.org/hib_docs/reference/en/html/assoc-bi directional-join.html
>>
>> Note that support for Teneo is given on the EMF newsgroup which I cc-ed.
>>
>> gr. Martin
>>
>> RJDAG wrote:
>>> Hello
>>>
>>> I am new to Teneo and Emf.
>>> The modeling associations article on the elever website did give me some
>>> overview. (http://www.elver.org/hibernate/hibernate_relations.html) But
>>> Is
>>> there a more detailed article available anywhere?
>>>
>>> I am working with the library example
>>> I am trying to map the Writer to books relationshp as OneToMany
>>> relationship.
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
>>> upperBound="-1"
>>>
>>> eType="#//Book" eOpposite="#//Book/author">
>>>
>>> <eAnnotations source="teneo.jpa">
>>>
>>> <details key="appinfo" value="@OneToMany(mappedBy=&quot;author&quot;,
>>> indexed=false)"/>
>>>
>>> </eAnnotations>
>>>
>>> </eStructuralFeatures>
>>>
>>> But the mapping generated is always of type many-to-many.
>>>
>>> What am I doing wrong?
>>>
>>> Thanks
>>> RJ
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Cell: +31 (0)6 288 48 943
>> 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
Cell: +31 (0)6 288 48 943
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: modelling associations [message #427627 is a reply to message #427601] Tue, 24 February 2009 19:04 Go to previous message
Rachna Bakhru is currently offline Rachna BakhruFriend
Messages: 45
Registered: July 2009
Member
Thanks a lot , that was very helpful.
"Martin Taal" <mtaal@elver.org> wrote in message
news:gnvvt8$2nq$1@build.eclipse.org...
> Hi RJ,
> As a default Teneo will use join tables for non-containment relations. You
> can disable this by setting this persistence option to false:
> PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_ASSOCIATIONS
>
> When this option is false then you can set a join table for a an
> association by setting the @JoinTable annotation.
>
> As you are new to EMF, a containment relation is a parent-child relation
> whereby the child depends on the parent for its existence. In the library
> example, a writer and book are contained in a library. The writer and book
> relationship in this model is non-containment.
>
> The reason that Teneo (as a default) uses join tables for non-containment
> relations is that this is safer (less change on name clashes) when having
> very complex models with multiple inheritance.
>
> gr. Martin
>
> RJDAG wrote:
>> Thank you for the quick response.
>>
>> I found the cascadenotall example on the elver website:
>> http://www.elver.org/hibernate/ejb3_examples.html
>>
>> I wish to generate an hbm like
>> CascadeNotallAction_mysql_a_o_hibernate.hbm.xml but when i generate it
>> I get hibernate.hbm.xml.
>>
>> I do not want to use the write_books table to store theWriter to books
>> relationship.
>>
>> Thanks
>> RJ
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:gnv6a3$7ld$1@build.eclipse.org...
>>> Hi RJ,
>>> There is no more detailed article available then what is available on
>>> elver.org or the hibernate manual (or posts on the
>>> newsgroup).
>>>
>>> In this case there is a many-to-many present in the mapping, but it has
>>> the special attribute unique="true", which means
>>> it is in fact a one-to-many. A OneToMany annotation can still be mapped
>>> with a many-to-many in hbm (as long as it has
>>> unique="true"). See these parts of the hibernate manual:
>>> http://www.hibernate.org/hib_docs/reference/en/html/assoc-un idirectional-join.html
>>> http://www.hibernate.org/hib_docs/reference/en/html/assoc-bi directional-join.html
>>>
>>> Note that support for Teneo is given on the EMF newsgroup which I cc-ed.
>>>
>>> gr. Martin
>>>
>>> RJDAG wrote:
>>>> Hello
>>>>
>>>> I am new to Teneo and Emf.
>>>> The modeling associations article on the elever website did give me
>>>> some
>>>> overview. (http://www.elver.org/hibernate/hibernate_relations.html) But
>>>> Is
>>>> there a more detailed article available anywhere?
>>>>
>>>> I am working with the library example
>>>> I am trying to map the Writer to books relationshp as OneToMany
>>>> relationship.
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="books"
>>>> upperBound="-1"
>>>>
>>>> eType="#//Book" eOpposite="#//Book/author">
>>>>
>>>> <eAnnotations source="teneo.jpa">
>>>>
>>>> <details key="appinfo" value="@OneToMany(mappedBy=&quot;author&quot;,
>>>> indexed=false)"/>
>>>>
>>>> </eAnnotations>
>>>>
>>>> </eStructuralFeatures>
>>>>
>>>> But the mapping generated is always of type many-to-many.
>>>>
>>>> What am I doing wrong?
>>>>
>>>> Thanks
>>>> RJ
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Cell: +31 (0)6 288 48 943
>>> 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
> Cell: +31 (0)6 288 48 943
> 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:EMF validation with OCL in MetaModel
Next Topic:How to create custom constructors of model objects ?
Goto Forum:
  


Current Time: Sat Apr 27 00:40:18 GMT 2024

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

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

Back to the top