Home » Modeling » EMF » [Teneo] How to have non-indexed n:m relations with named join-columns
|
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 |
Martin Taal 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 #765191 is a reply to message #765186] |
Tue, 13 December 2011 15:29 |
Martin Taal 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 #765566 is a reply to message #765276] |
Wed, 14 December 2011 10:06 |
Ed Merks 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/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 06:19:40 GMT 2024
Powered by FUDForum. Page generated in 0.03936 seconds
|