Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] [Teneo] [Hibernate] Reference on NON Primary Key
[EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #815899] Thu, 08 March 2012 07:12 Go to next message
Nils Koerner is currently offline Nils KoernerFriend
Messages: 5
Registered: March 2012
Junior Member
Hallo,

i have 2 EClasses:

Class Person
- ID = PrimaryKey
- Name
- otherUniqueID

Class Adress
- ID = PrimaryKey
- person = Refrence to Person.otherUniqueID
- street
- city

I use a Ecore-Model with Teneo and Hibernate. The problem is, that i dont know the annotation for the person-reference in class "Adress". Does anybody know, how to do that??

Many thanks
Nils
Re: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #816059 is a reply to message #815899] Thu, 08 March 2012 11:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Nils,
Can you try this one:
@JoinColumn(referencedColumnName="otherUniqueID")
in the Address.person ereference
the referencedColumnName can be the efeature name on the other side.

gr. Martin

On 03/08/2012 08:12 AM, Nils Koerner wrote:
> Hallo,
>
> i have 2 EClasses:
>
> Class Person
> - ID = PrimaryKey
> - Name
> - otherUniqueID
>
> Class Adress
> - ID = PrimaryKey
> - person = Refrence to Person.otherUniqueID
> - street
> - city
>
> I use a Ecore-Model with Teneo and Hibernate. The problem is, that i dont know the annotation for the person-reference
> in class "Adress". Does anybody know, how to do that??
>
> Many thanks
> Nils


--

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: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #818936 is a reply to message #815899] Mon, 12 March 2012 09:48 Go to previous messageGo to next message
Nils Koerner is currently offline Nils KoernerFriend
Messages: 5
Registered: March 2012
Junior Member
Hi Martin,

thank you very much for your quick reply. I have defined an annotation on the specified reference (Address.person):

@JoinColumn(name = "key", referencedColumnName="otherUniqueID")

Unfortunately it doesnt work. The first parameter (name = "key") is beeing executed but the second parameter (referencedColumnName="otherUniqueID") is beeing ignored without any error message. Adress.person is still referenced with Person.id. Any idea?

Thank you Smile
Nils

Re: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #818991 is a reply to message #818936] Mon, 12 March 2012 10:56 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Nils,
Did you regenerate the java code? This is needed when adding annotations to the model, as EMF generates java code which
builds the model at runtime.

gr. Martin

On 03/12/2012 10:48 AM, Nils Koerner wrote:
> Hi Martin,
>
> thank you very much for your quick reply. I have defined an annotation on the specified reference (Address.person):
>
> @JoinColumn(name = "key", referencedColumnName="otherUniqueID")
>
> Unfortunately it doesnt work. The first parameter (name = "key") is beeing executed but the second parameter
> (referencedColumnName="otherUniqueID") is beeing ignored without any error message. Adress.person is still referenced
> with Person.id. Any idea?
>
> Thank you :)
> Nils
>
>


--

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: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #819001 is a reply to message #818991] Mon, 12 March 2012 11:10 Go to previous messageGo to next message
Nils Koerner is currently offline Nils KoernerFriend
Messages: 5
Registered: March 2012
Junior Member
Hi Martin,

yes, i regenerated the model. It seems that teneo ignores the 2nd part of the annotation.

Greetings
Nils
Re: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #819025 is a reply to message #819001] Mon, 12 March 2012 11:51 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you try putting it in an enclosing JoinColumns annotation:
@JoinColumns({@JoinColumn(name = "key", referencedColumnName="otherUniqueID")})

This format I have in several testcases.

gr. Martin

On 03/12/2012 12:10 PM, Nils Koerner wrote:
> Hi Martin,
>
> yes, i regenerated the model. It seems that teneo ignores the 2nd part of the annotation.
>
> Greetings
> Nils
>


--

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: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #819040 is a reply to message #819025] Mon, 12 March 2012 12:15 Go to previous messageGo to next message
Nils Koerner is currently offline Nils KoernerFriend
Messages: 5
Registered: March 2012
Junior Member
The database-field with the specified name (for example "key111") is created, but the reference is still on the primary key.

greetings,
Nils
Re: [EMF] [Teneo] [Hibernate] Reference on NON Primary Key [message #819120 is a reply to message #819040] Mon, 12 March 2012 14:18 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Okay, how does the generated hbm look like (you can check it through dataStore.getMappingXML()).

gr. Martin

On 03/12/2012 01:15 PM, Nils Koerner wrote:
> The database-field with the specified name (for example "key111") is created, but the reference is still on the primary
> key.
>
> greetings,
> Nils


--

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:Type arguments lost when generating code
Next Topic:EMF Storage
Goto Forum:
  


Current Time: Fri Mar 29 13:27:10 GMT 2024

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

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

Back to the top