Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] ORM.xml generation for bi-directional refs(The generator seems to always generate redundant join-tables)
icon7.gif  [Texo] ORM.xml generation for bi-directional refs [message #742333] Thu, 20 October 2011 12:01 Go to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Hi all,

I am very excitedly using texo for the last few days.
Creating an orm.xml from a given ecore works like a charm.

Great!
But now to my current problem:

I tried to create a bi-directional 1:n relation between two classes.
I used two EReferences refering from one class to the other which have each other as their EOpposite.

Consider the following Example:

Class "Content"                                 Class "Module"
 [some content attributes...]                    [some module attributes...]
 EReference "module" ------------------------------> (0..1)
         (0..*) <------------------------------- EReference "contents"


I would expect that the generated orm.xml would simply contain one additional column for CONTENT. In fact it does. But there is also a newly created join-table for MODULE_CONTENTS which contains the same relations.

I would expect the usage of the "mapped-by"-attribute in the "reverse"-relation instead of saving the key-mappings redundantly in another join-table...

The situation gets even worse, when creating a n:m relation. Then there are two join-tables (CONTENT_MODULE and MODULE_CONTENT) redundantly containing the relation info. And again I can manually edit orm.xml and do some "reverse" settings on one side to get only one join-table...

I cannot believe that I am the first one encountering such problems...
So what is it that am I missing?

Thanks in advance,
R. Oldenburg

[Updated on: Thu, 20 October 2011 14:38]

Report message to a moderator

Re: [Texo] ORM.xml generation for bi-directional refs [message #742485 is a reply to message #742333] Thu, 20 October 2011 14:37 Go to previous messageGo to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Never mind...
I got it...

Stupid me...

I simply forgot to watch over the "order" setting of the EReferences.
Forcing an "order=true" on the relation causes an index creation on both sides. And index creation for a mapping is only possible when using a dedicated join table.

Maybe this entry will help some other rookie. Smile

So solution was to simply set "order=false" on the "slave" side.
And voila: Only one join-table is used.

Thanks a lot to the team for this great framework/tool TEXO!
Re: [Texo] ORM.xml generation for bi-directional refs [message #742550 is a reply to message #742485] Thu, 20 October 2011 15:38 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
Good that it works, note that you can enrich the model with annotations to control the orm generation.
There are 2 properties which control the usage of join tables. See the attachment. For more information on annotations:
http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details

gr. Martin


On 10/20/2011 04:37 PM, R. Oldenburg wrote:
> Never mind...
> I got it...
>
> Stupid me...
>
> I simply forgot to watch over the "order" setting of the EReferences.
> Forcing an "order=true" on the relation causes an index creation on both sides. And index creation for a mapping is only
> possible when using a dedicated join table.
>
> Maybe this entry will help some other rookie. :)
>
> So solution was to simply set "order=false" on the "slave" side.
> And voila: Only one join-table is used.
>
> Thanks a lot to the team for this great framework/tool TEXO!
>


--

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: [Texo] ORM.xml generation for bi-directional refs [message #742731 is a reply to message #742550] Thu, 20 October 2011 19:26 Go to previous messageGo to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Yeah I know (found it in another thread concerning join-tables).
Thanks. I Already used it, but was irritated because I still had multiple join-tables. Smile

BTW: Is there any possibility to "remove", "deactivate" or "disallow" default texo annotations?
As far as I can see, one can only edit or add annotations... Correct?

[Updated on: Thu, 20 October 2011 19:27]

Report message to a moderator

Re: [Texo] ORM.xml generation for bi-directional refs [message #742794 is a reply to message #742731] Thu, 20 October 2011 21:04 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Correct that's not possible, what do you want to deactivate/disallow?

gr. Martin

On 10/20/2011 09:26 PM, R. Oldenburg wrote:
> Yeah I know (found it in another thread concenring join-tables).
> Thanks. I Already used it, but was irritated because I still had multiple join-tables. :)
>
> BTW: Is there any possibility to "remove", "deactivate" or "disallow" default texo annotations?
> As far as I can see, one can only edit or add annotations... Correct?
>


--

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: [Texo] ORM.xml generation for bi-directional refs [message #743142 is a reply to message #742794] Fri, 21 October 2011 06:55 Go to previous messageGo to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Smile

As we found the explanation for the original problem I am running out of a senseful example...
As a first guess we tried to override the join-table/column mapping. Which was not possible through the ORM annotation model.
That led to this question. But couldn't it be that somebody needs to override/remove some (generated) mapping behaviour?

I recognized some "Attribute override" annotations. Is this standard ORM? Or is it texo specific?
If so, is there any doc covering these texo specific annotations?

And concerning the original problem in the first post:
Wouldn't it be good to take these infos ("ordering sometimes causes creation of some additional mapping objects") into the "Troubleshooting" part of the Texo wiki?

I (more or less) accidentally found the explanation for this behavior in the *Teneo* wiki (have already forgot which page).

Thanks for bothering.
Regards,
Re: [Texo] ORM.xml generation for bi-directional refs [message #743327 is a reply to message #743142] Fri, 21 October 2011 10:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
The annotations can be used to override the standard Texo behavior. But only if used more or less logically, so if you
add a OneToOne annotation on a many ereference then Texo will probably still generate a OneToMany in the orm.xml.

I added a comment here:
http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details#Texo_Mapping_Decisions

gr. Martin

On 10/21/2011 08:55 AM, R. Oldenburg wrote:
> :)
>
> As we found the explanation for the original problem I am running out of a senseful example... As a first guess we tried
> to override the join-table/column mapping. Which was not possible through the ORM annotation model.
> That led to this question. But couldn't it be that somebody needs to override/remove some (generated) mapping behaviour?
>
> I recognized some "Attribute override" annotations. Is this standard ORM? Or is it texo specific?
> If so, is there any doc covering these texo specific annotations?
>
> And concerning the original problem in the first post:
> Wouldn't it be good to take these infos ("ordering sometimes causes creation of some additional mapping objects") into
> the "Troubleshooting" part of the Texo wiki?
>
> I (more or less) accidentally found the explanation for this behavior in the *Teneo* wiki (have already forgot which page).
>
> Thanks for bothering.
> Regards,
>


--

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: [Texo] ORM.xml generation for bi-directional refs [message #745309 is a reply to message #743327] Sat, 22 October 2011 18:42 Go to previous messageGo to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Hey,

thanks for your explanation and the addition to the documentation.

Have taken a look at it.
"When ... ordered, use a list..., then they will mapped..." sounds like a typo for me...

Now concerning the annotations:
Sure the "removals/replacements" have to be senseful. We still have no working example. Every time we had one it turned out to be incomplete in some way.

Maybe it is just our very small experience with generated ORM solutions.
I will be clearer when our first Texo-driven project is finished.

Again: Thanks a lot.

R.O.
Re: [Texo] ORM.xml generation for bi-directional refs [message #745533 is a reply to message #745309] Sat, 22 October 2011 22:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Rephrased, thanks.

gr. Martiin

On 10/22/2011 08:42 PM, R. Oldenburg wrote:
> Hey,
>
> thanks for your explanation and the addition to the documentation.
>
> Have taken a look at it. "When ... ordered, use a list..., then they will mapped..." sounds like a typo for me...
>
> Now concerning the annotations:
> Sure the "removals/replacements" have to be senseful. We still have no working example. Every time we had one it turned
> out to be incomplete in some way.
>
> Maybe it is just our very small experience with generated ORM solutions.
> I will be clearer when our first Texo-driven project is finished.
>
> Again: Thanks a lot.
>
> R.O.


--

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:Howto use xsd2Ecore so that the xmi-files can be validated with xsd?
Next Topic:[EEF] procedure to generate context help documenation?
Goto Forum:
  


Current Time: Fri Oct 23 12:17:49 GMT 2020

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

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

Back to the top