Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] How to have non-indexed n:m relations with named join-columns
[Teneo] How to have non-indexed n:m relations with named join-columns [message #765161] Tue, 13 December 2011 14:35 Go to next message
Jan Haensli is currently offline Jan HaensliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi all

I am trying to annotate my model to have an non-indexed many-to-many relationship with named join-columns.

According to [1],[2] this shall look something like this:

@ManyToMany(indexed=false)
@JoinTable(
   joinColumns=@JoinColumn(name="CUST_ID", referencedColumnName="ID"),
   inverseJoinColumns=@JoinColumn(name="PHONE_ID", referencedColumnName="ID")
)
public Set getPhones() { return phones; }


Unfortunately, this does not work. The n:m-table contains the index-column.
If I ommit the custom join-column names and thus only set indexed=false like below the n:m-table is non indexed (which would be ok except the non-custom-column names).

@ManyToMany(indexed=false)
public Set getPhones() { return phones; }


Does someone know, how to annotate the method to have non-indexed n:m mappings with custom join-column names?

I use EMF 2.5.0, Hibernate 3.4.0.GA, Teneo 1.1.2
(existing project)

I appreciate any hints or pointers!

Jan


[1] htp://docs.oracle.com/javaee/5/api/javax/persistence/ManyToMany.html
[2] htp://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Association_Mapping#Mapping_non-indexed_nm_relations
Re: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765171 is a reply to message #765161] Tue, 13 December 2011 14:49 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jan,
It seems that you are annotating the java source code, Teneo uses model annotations, these need to be specified in the
ecore model:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Annotations_Format

If you are using EMF server side then the following EMF project maybe of interest, it generates annotations in the java
code which can be manually changed, see here for a blog post:
http://martintaal.wordpress.com/2011/10/26/texo-generate-jpa-annotated-pojos-from-ecorexsd/

It also has other differentiators compared to EMF:
http://martintaal.wordpress.com/2011/12/06/emft-texo-different-from-emf-code-generation/

gr. Martin

On 12/13/2011 03:35 PM, Jan Haensli wrote:
> Hi all
>
> I am trying to annotate my model to have an non-indexed many-to-many relationship with named join-columns.
>
> According to [1],[2] this shall look something like this:
>
>
> @ManyToMany(indexed=false)
> @JoinTable(
> joinColumns=@JoinColumn(name="CUST_ID", referencedColumnName="ID"),
> inverseJoinColumns=@JoinColumn(name="PHONE_ID", referencedColumnName="ID")
> )
> public Set getPhones() { return phones; }
>
>
> Unfortunately, this does not work. The n:m-table contains the index-column.
> If I ommit the custom join-column names and thus only set indexed=false like below the n:m-table is non indexed (which
> would be ok except the non-custom-column names).
>
>
> @ManyToMany(indexed=false)
> public Set getPhones() { return phones; }
>
>
> Does someone know, how to annotate the method to have non-indexed n:m mappings with custom join-column names?
>
> I use EMF 2.5.0, Hibernate 3.4.0.GA, Teneo 1.1.2
> (existing project)
>
> I appreciate any hints or pointers!
>
> Jan
>
>
> [1] htp://docs.oracle.com/javaee/5/api/javax/persistence/ManyToMany.html
> [2] htp://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Association_Mapping#Mapping_non-indexed_nm_relations


--

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: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765177 is a reply to message #765171] Tue, 13 December 2011 15:07 Go to previous messageGo to next message
Jan Haensli is currently offline Jan HaensliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Martin

Thanks for the quick reply!

Sorry, for the mistake/confusion:
I am using model annotations, but for the sake of simplicity I pasted adapted examples from the JPA doc.

Actually, what I have is this:

    /**
     * @return
     * @model annotation="teneo.jpa appinfo='@ManyToMany(indexed=false) @JoinTable(indexed=false joinColumns=
     * @JoinColumn(name="COMPENSATIONACCOUNT_ID", referencedColumnName="ID"), inverseJoinColumns=
     * @JoinColumn(name="SHARECLASS_ID", referencedColumnName="ID") )'"
     */
    EList<ShareClass> getAssignedShareClasses();


The above "annotations" work, except that the n:m-table contains the index column.

Thanks for looking at this again.

Jan









Re: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765186 is a reply to message #765177] Tue, 13 December 2011 15:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Isn't the index column created because your list is marked as ordered?
Hence it is mapped to list in hbm.xml and not a bag.

Simply set the ordered =false in your ecore.

Tom

Am 13.12.11 16:07, schrieb Jan Haensli:
> Hi Martin
>
> Thanks for the quick reply!
>
> Sorry, for the mistake/confusion:
> I am using model annotations, but for the sake of simplicity I pasted
> adapted examples from the JPA doc.
>
> Actually, what I have is this:
>
>
> /**
> * @return
> * @model annotation="teneo.jpa appinfo='@ManyToMany(indexed=false)
> @JoinTable(indexed=false joinColumns=
> * @JoinColumn(name="COMPENSATIONACCOUNT_ID",
> referencedColumnName="ID"), inverseJoinColumns=
> * @JoinColumn(name="SHARECLASS_ID", referencedColumnName="ID") )'"
> */
> EList<ShareClass> getAssignedShareClasses();
>
>
> The above "annotations" work, except that the n:m-table contains the
> index column.
>
> Thanks for looking at this again.
>
> Jan
>
>
>
>
>
>
>
>
>
>
Re: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765191 is a reply to message #765186] Tue, 13 December 2011 15:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes setting ordered to false helps and there is a persistence option to let all lists to be mapped as a bag (so without
an index), which can be used.
Still strange that the indexed=false is not picked up. Note that after adding/changing annotations in the model you have
to regenerate the source code as the annotations are then present at runtime.

gr. Martin

On 12/13/2011 04:18 PM, Tom Schindl wrote:
> Isn't the index column created because your list is marked as ordered?
> Hence it is mapped to list in hbm.xml and not a bag.
>
> Simply set the ordered =false in your ecore.
>
> Tom
>
> Am 13.12.11 16:07, schrieb Jan Haensli:
>> Hi Martin
>>
>> Thanks for the quick reply!
>>
>> Sorry, for the mistake/confusion:
>> I am using model annotations, but for the sake of simplicity I pasted
>> adapted examples from the JPA doc.
>>
>> Actually, what I have is this:
>>
>>
>> /**
>> * @return
>> * @model annotation="teneo.jpa appinfo='@ManyToMany(indexed=false)
>> @JoinTable(indexed=false joinColumns=
>> * @JoinColumn(name="COMPENSATIONACCOUNT_ID",
>> referencedColumnName="ID"), inverseJoinColumns=
>> * @JoinColumn(name="SHARECLASS_ID", referencedColumnName="ID") )'"
>> */
>> EList<ShareClass> getAssignedShareClasses();
>>
>>
>> The above "annotations" work, except that the n:m-table contains the
>> index column.
>>
>> Thanks for looking at this again.
>>
>> Jan
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>


--

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: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765276 is a reply to message #765191] Tue, 13 December 2011 18:50 Go to previous messageGo to next message
Jan Haensli is currently offline Jan HaensliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Tom, Martin

Changing the ecore property "ordered" to "false" works! Thanks!

As I use the Java model as a base for all settings I need a way to set ordered=false on my EMF model. (Otherwise after regenerating the model the setting is lost)

@model ordered="false"

does not seem to work. Any idea how I have to annotate the java model to have ordered=false on the ecore model?


I do reload and re-generate the model each time I amend the annotations on the Java EMF Model. But as mentioned, indexed=false seems to be ignored, when the @JoinTable annotation is there as well.


Cheers

Jan

Re: [Teneo] How to have non-indexed n:m relations with named join-columns [message #765566 is a reply to message #765276] Wed, 14 December 2011 10:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jan,

Comments below.

On 13/12/2011 7:50 PM, Jan Haensli wrote:
> Hi Tom, Martin
>
> Changing the ecore property "ordered" to "false" works! Thanks!
>
> As I use the Java model as a base for all settings I need a way to set
> ordered=false on my EMF model. (Otherwise after regenerating the model
> the setting is lost)
>
>
> @model ordered="false"
>
> does not seem to work
It works for me. I'm not sure what the problem might be without more
information.
> . Any idea how I have to annotate the java model to have
> ordered=false on the ecore model?
>
>
> I do reload and re-generate the model each time I amend the
> annotations on the Java EMF Model. But as mentioned, indexed=false
> seems to be ignored, when the @JoinTable annotation is there as well.
>
>
> Cheers
>
> Jan
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF Compare] EMFCompare is useless in EGit's merge tool?
Next Topic:[Teneo] combining a @ManyToMany and a @OneToMany between 2 entities, how to?
Goto Forum:
  


Current Time: Thu Apr 25 06:19:40 GMT 2024

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

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

Back to the top