Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] overwrite @CollectionTable with the ORM file(How to override @CollectionTable)
[Texo] overwrite @CollectionTable with the ORM file [message #1171919] Tue, 05 November 2013 15:28 Go to next message
gabriele Mising name is currently offline gabriele Mising nameFriend
Messages: 19
Registered: December 2009
Junior Member
Hi,

I created an model: the entity "A0" has an attribute "att2" (@ElementCollection)
"A0" is an interface. "A1" and "A2" extend "A0".
In these two classes I want to rename the relation "att2" to have two tables in the database.
I tried to create the file orm but without success: the generator always puts me in the same name: "test1_A0_att2," even if the redefined attribute att2 at the level of classes A1 and A2.

index.php/fa/16662/0/

How do I change this value?
I attach the model and its orm file


A1 {
...	
@ElementCollection()
@CollectionTable(name = "test1_A0_att2")   <- the value should be "test1_A1_att2"
private List<Long> att2 = new ArrayList<Long>();
...
}

A2 {
...	
@ElementCollection()
@CollectionTable(name = "test1_A0_att2")      <- the value should be "test1_A2_att2"
private List<Long> att2 = new ArrayList<Long>();
...
}
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1172393 is a reply to message #1171919] Tue, 05 November 2013 22:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
Yes I see your point/issue. But I am not sure what a good approach is here... The annotationsmodel references the
efeature from the interface eclass. There is no efeature in the subclasses.
So nothing to attach a JPA annotation to. No associationoverride or attributeoverride either.

Can you find an example on the net which does what you want in standard JPA?

gr. Martin

On 11/05/2013 04:28 PM, gabriele boldrin wrote:
> Hi,
>
> I created an model: the entity "A0" has an attribute "att2" (@ElementCollection)
> "A0" is an interface. "A1" and "A2" extend "A0".
> In these two classes I want to rename the relation "att2" to have two tables in the database.
> I tried to create the file orm but without success: the generator always puts me in the same name: "test1_A0_att2," even if the redefined attribute att2 at the level of classes A1 and A2.
>
>
>
> How do I change this value?
> I attach the model and its orm file
>
>
>
> A1 {
> ...
> @ElementCollection()
> @CollectionTable(name = "test1_A0_att2") <- the value should be "test1_A1_att2"
> private List<Long> att2 = new ArrayList<Long>();
> ...
> }
>
> A2 {
> ...
> @ElementCollection()
> @CollectionTable(name = "test1_A0_att2") <- the value should be "test1_A2_att2"
> private List<Long> att2 = new ArrayList<Long>();
> ...
> }
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1173138 is a reply to message #1172393] Wed, 06 November 2013 10:06 Go to previous messageGo to next message
gabriele Mising name is currently offline gabriele Mising nameFriend
Messages: 19
Registered: December 2009
Junior Member
Hi Martin,


I have not found an example.
I've done some generation tests.

By default in the "att2", the generator puts: "@​​ElementCollection" and "@ CollectionTable" to define the name of the table.

Generated code :

A1 { 
...
@ ElementCollection ( )
@ CollectionTable ( name = " test1_A0_att2 " )
private List <long> att2 <long> = new ArrayList ();
...}


A2 { 
...
@ ElementCollection ( )
@ CollectionTable ( name = " test1_A0_att2 " )
private List <long> att2 <long> = new ArrayList ();
...}


In this case JPA fails to create the database because there is a name conflict: A1 and A2 share the same table created for the attribute att2.

TABLE :
table_a1
table_a0_att2 <---- conflict. The tables are not created
table_a2
table_a0_att2 <---- conflict. The tables are not created


If you delete the annotation "@CollectionTable" from the code, then JPA successfully creates the tables:


A1 { 
...
@ ElementCollection ( )
//@CollectionTable ( name = "test1_A0_att2") <--remove or rename in "test1_A1_att2" 
private List <long> att2 <long> = new ArrayList ();
...}


A2 { 
...
@ ElementCollection ( )
//@CollectionTable ( name = "test1_A0_att2") <--remove or rename in "test1_A2_att2" 
private List <long> att2 <long> = new ArrayList ();
...}


TABLE :
table_a1
table_a1_att2
table_a2
table_a2_att2


I think that by default, texo must not put the @CollectionTable.





Re: [Texo] overwrite @CollectionTable with the ORM file [message #1173442 is a reply to message #1173138] Wed, 06 November 2013 14:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
I think there is an option/setting on the epackage orm annotation: generateFullDbSchemaNames
the default is true, can you set it at false?

gr. Martin

On 11/06/2013 11:06 AM, gabriele boldrin wrote:
> Hi Martin,
>
>
> I have not found an example.
> I've done some generation tests.
>
> By default in the "att2", the generator puts: "@​​ElementCollection" and "@ CollectionTable" to define the name of the
> table.
>
> Generated code :
>
>
> A1 { ...
> @ ElementCollection ( )
> @ CollectionTable ( name = " test1_A0_att2 " )
> private List <long> att2 <long> = new ArrayList ();
> ...}
>
>
> A2 { ...
> @ ElementCollection ( )
> @ CollectionTable ( name = " test1_A0_att2 " )
> private List <long> att2 <long> = new ArrayList ();
> ...}
>
>
> In this case JPA fails to create the database because there is a name conflict: A1 and A2 share the same table created
> for the attribute att2.
>
> TABLE :
> table_a1
> table_a0_att2 <---- conflict. The tables are not created
> table_a2
> table_a0_att2 <---- conflict. The tables are not created
>
>
> If you delete the annotation "@CollectionTable" from the code, then JPA successfully creates the tables:
>
>
>
> A1 { ...
> @ ElementCollection ( )
> //@CollectionTable ( name = "test1_A0_att2") <--remove or rename in "test1_A1_att2" private List <long> att2 <long> =
> new ArrayList ();
> ...}
>
>
> A2 { ...
> @ ElementCollection ( )
> //@CollectionTable ( name = "test1_A0_att2") <--remove or rename in "test1_A2_att2" private List <long> att2 <long> =
> new ArrayList ();
> ...}
>
>
> TABLE :
> table_a1
> table_a1_att2
> table_a2
> table_a2_att2
>
>
> I think that by default, texo must not put the @CollectionTable.
>
>
>
>
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1173547 is a reply to message #1173442] Wed, 06 November 2013 15:48 Go to previous messageGo to next message
gabriele Mising name is currently offline gabriele Mising nameFriend
Messages: 19
Registered: December 2009
Junior Member
Hi,

I've already tried. The flag is set to false.
The annotation "@CollectionTable" is always generated.
If I create the file orm, texo always puts the annotation.

index.php/fa/16670/0/
  • Attachment: img2.jpg
    (Size: 65.02KB, Downloaded 501 times)
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1174003 is a reply to message #1173547] Wed, 06 November 2013 22:13 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
Okay what happens if you have this option to false and then also remove the relevant annotations in the annotations model?

gr. Martin

On 11/06/2013 04:48 PM, gabriele boldrin wrote:
> Hi,
>
> I've already tried. The flag is set to false.
> The annotation "@CollectionTable" is always generated.
> If I create the file orm, texo always puts the annotation.
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1174695 is a reply to message #1174003] Thu, 07 November 2013 09:02 Go to previous messageGo to next message
gabriele Mising name is currently offline gabriele Mising nameFriend
Messages: 19
Registered: December 2009
Junior Member
Hi,
I have set option to false.
I have generated the code without having the orm file and I get this:

A1 { ...
@ ElementCollection ( )
@ CollectionTable ( name = " test1_A0_att2 " )
private List <long> att2 <long> = new ArrayList ();
...}

A2 { ...
@ ElementCollection ( )
@ CollectionTable ( name = " test1_A0_att2 " )
private List <long> att2 <long> = new ArrayList ();
...}



I have generated the ORM file and I see that I put the annotation "@CollectionTable" by default.
I remove the annotation "@CollectionTable" from the file, but texo continues to put the annotation of the generated code.
I do not have the possibility to remove the annotation or overwrite the annotation.
In my first post there is a model for testing.
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1174731 is a reply to message #1174695] Thu, 07 November 2013 09:30 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
To prevent confusion, did you test without the orm file or without the annotationsmodel file?

gr. Martin

On 11/07/2013 10:02 AM, gabriele boldrin wrote:
> Hi, I have set option to false.
> I have generated the code without having the orm file and I get this:
>
>
> A1 { ...
> @ ElementCollection ( )
> @ CollectionTable ( name = " test1_A0_att2 " )
> private List <long> att2 <long> = new ArrayList ();
> ...}
>
> A2 { ...
> @ ElementCollection ( )
> @ CollectionTable ( name = " test1_A0_att2 " )
> private List <long> att2 <long> = new ArrayList ();
> ...}
>
>
>
> I have generated the ORM file and I see that I put the annotation "@CollectionTable" by default.
> I remove the annotation "@CollectionTable" from the file, but texo continues to put the annotation of the generated code.
> I do not have the possibility to remove the annotation or overwrite the annotation.
> In my first post there is a model for testing.
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1174759 is a reply to message #1174731] Thu, 07 November 2013 09:48 Go to previous messageGo to next message
gabriele Mising name is currently offline gabriele Mising nameFriend
Messages: 19
Registered: December 2009
Junior Member
Hi,

I'm sorry, without the annotationsmodel file.
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1186370 is a reply to message #1174759] Thu, 14 November 2013 17:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
There was a bug in Texo which ment that for collectiontable always a table name was set. I have corrected this and
pushed a new bug.

Still this only solves part of the issue, nl. when no name is set the ORM layer will choose it. I don't have a solution
that 2 impl classes can use different annotations for an inherited feature. Other than using associationoverride which
does not support collectiontable, and I am not sure if the interface is viewed as the superclass of the impl classes either.

In any case I hope it already helps if you don't specify the name attribute of the CollectionTable annotation. Btw, to
try it you have to remove the CollectionTable annotation completely and also have generate full db schema to false.

gr. Martin

On 11/07/2013 10:48 AM, gabriele boldrin wrote:
> Hi,
> I'm sorry, without the annotationsmodel file.


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] overwrite @CollectionTable with the ORM file [message #1186371 is a reply to message #1186370] Thu, 14 November 2013 17:13 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
I ofcourse pushed a new fix :-), I published a new build containing this fix also.

gr. Martin

On 11/14/2013 06:12 PM, Martin Taal wrote:
> Hi Gabriele,
> There was a bug in Texo which ment that for collectiontable always a table name was set. I have corrected this and
> pushed a new bug.
>
> Still this only solves part of the issue, nl. when no name is set the ORM layer will choose it. I don't have a solution
> that 2 impl classes can use different annotations for an inherited feature. Other than using associationoverride which
> does not support collectiontable, and I am not sure if the interface is viewed as the superclass of the impl classes
> either.
>
> In any case I hope it already helps if you don't specify the name attribute of the CollectionTable annotation. Btw, to
> try it you have to remove the CollectionTable annotation completely and also have generate full db schema to false.
>
> gr. Martin
>
> On 11/07/2013 10:48 AM, gabriele boldrin wrote:
>> Hi,
>> I'm sorry, without the annotationsmodel file.
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:[Texo] NullPointerException generating Ecore from XSD
Next Topic:[EMFStore] customizing date equality
Goto Forum:
  


Current Time: Thu Apr 18 05:30:37 GMT 2024

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

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

Back to the top