Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Setting a 'unique' constraint on a many-to-one reference in hibernate
[Teneo] Setting a 'unique' constraint on a many-to-one reference in hibernate [message #69943] Fri, 02 February 2007 06:17 Go to next message
Eclipse UserFriend
Originally posted by: Stephen.Egan.csiro.au

Hi,
I'm trying to add a unique constraint to a many-to-one Ereference in my =
=

ecore model using Eannotaions. I've added the following Eannotation to =
=

the Ereference:

<eStructuralFeatures xsi:type=3D"ecore:EReference" name=3D"userAc=
count" =

eType=3D"#//Support/UserAccount">
<eAnnotations source=3D"teneo.hibernate">
<details key=3D"appinfo" value=3D"@Column(unique=3D&quot;true=
&quot;)"/>
</eAnnotations>
</eStructuralFeatures>

This works fine for an Eattribute, but doesn't seem to have any effect o=
n =

the generated hibernate mappings for an EReference:

<many-to-one name=3D"userAccount" entity-name=3D"UserAccount" =

cascade=3D"merge,persist,save-update,lock,refresh" lazy=3D"false" =

insert=3D"true" update=3D"true" not-null=3D"false">
<column not-null=3D"false" unique=3D"false" =

name=3D"`useraccount_useraccount_id`"/>
</many-to-one>

I'm still new to fiddling about with the Eannotations, so please forgive=
=

me if this is a dumb question.

//Stephen
Re: [Teneo] Setting a 'unique' constraint on a many-to-one reference in hibernate [message #69963 is a reply to message #69943] Fri, 02 February 2007 07:53 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Stephen,
No dumb question, on an ereference you can use the JoinColumn annotation for this (so just replace
Column with JoinColumn).

gr. Martin

Stephen Egan wrote:
> Hi,
> I'm trying to add a unique constraint to a many-to-one Ereference in my
> ecore model using Eannotaions. I've added the following Eannotation to
> the Ereference:
>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="userAccount" eType="#//Support/UserAccount">
> <eAnnotations source="teneo.hibernate">
> <details key="appinfo" value="@Column(unique=&quot;true&quot;)"/>
> </eAnnotations>
> </eStructuralFeatures>
>
> This works fine for an Eattribute, but doesn't seem to have any effect
> on the generated hibernate mappings for an EReference:
>
> <many-to-one name="userAccount" entity-name="UserAccount"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`useraccount_useraccount_id`"/>
> </many-to-one>
>
> I'm still new to fiddling about with the Eannotations, so please forgive
> me if this is a dumb question.
>
> //Stephen


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Setting a 'unique' constraint on a many-to-one reference in hibernate [message #70508 is a reply to message #69963] Tue, 06 February 2007 00:48 Go to previous message
Eclipse UserFriend
Originally posted by: Stephen.Egan.csiro.au

Thanks Martin,
Prompt and accurate as usual!

///Stephen

On Fri, 02 Feb 2007 18:53:27 +1100, Martin Taal <mtaal@elver.org> wrote:=


> Hi Stephen,
> No dumb question, on an ereference you can use the JoinColumn annotati=
on =

> for this (so just replace Column with JoinColumn).
>
> gr. Martin
>
> Stephen Egan wrote:
>> Hi,
>> I'm trying to add a unique constraint to a many-to-one Ereference in =
my =

>> ecore model using Eannotaions. I've added the following Eannotation =
to =

>> the Ereference:
>> <eStructuralFeatures xsi:type=3D"ecore:EReference" =

>> name=3D"userAccount" eType=3D"#//Support/UserAccount">
>> <eAnnotations source=3D"teneo.hibernate">
>> <details key=3D"appinfo" =

>> value=3D"@Column(unique=3D&quot;true&quot;)"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> This works fine for an Eattribute, but doesn't seem to have any effe=
ct =

>> on the generated hibernate mappings for an EReference:
>> <many-to-one name=3D"userAccount" entity-name=3D"UserAccount=
" =

>> cascade=3D"merge,persist,save-update,lock,refresh" lazy=3D"false" =

>> insert=3D"true" update=3D"true" not-null=3D"false">
>> <column not-null=3D"false" unique=3D"false" =

>> name=3D"`useraccount_useraccount_id`"/>
>> </many-to-one>
>> I'm still new to fiddling about with the Eannotations, so please =

>> forgive me if this is a dumb question.
>> //Stephen
>
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: [Teneo] Setting a 'unique' constraint on a many-to-one reference in hibernate [message #601973 is a reply to message #69943] Fri, 02 February 2007 07:53 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Stephen,
No dumb question, on an ereference you can use the JoinColumn annotation for this (so just replace
Column with JoinColumn).

gr. Martin

Stephen Egan wrote:
> Hi,
> I'm trying to add a unique constraint to a many-to-one Ereference in my
> ecore model using Eannotaions. I've added the following Eannotation to
> the Ereference:
>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="userAccount" eType="#//Support/UserAccount">
> <eAnnotations source="teneo.hibernate">
> <details key="appinfo" value="@Column(unique=&quot;true&quot;)"/>
> </eAnnotations>
> </eStructuralFeatures>
>
> This works fine for an Eattribute, but doesn't seem to have any effect
> on the generated hibernate mappings for an EReference:
>
> <many-to-one name="userAccount" entity-name="UserAccount"
> cascade="merge,persist,save-update,lock,refresh" lazy="false"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`useraccount_useraccount_id`"/>
> </many-to-one>
>
> I'm still new to fiddling about with the Eannotations, so please forgive
> me if this is a dumb question.
>
> //Stephen


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Setting a 'unique' constraint on a many-to-one reference in hibernate [message #602179 is a reply to message #69963] Tue, 06 February 2007 00:48 Go to previous message
Eclipse UserFriend
Originally posted by: Stephen.Egan.csiro.au

Thanks Martin,
Prompt and accurate as usual!

///Stephen

On Fri, 02 Feb 2007 18:53:27 +1100, Martin Taal <mtaal@elver.org> wrote:=


> Hi Stephen,
> No dumb question, on an ereference you can use the JoinColumn annotati=
on =

> for this (so just replace Column with JoinColumn).
>
> gr. Martin
>
> Stephen Egan wrote:
>> Hi,
>> I'm trying to add a unique constraint to a many-to-one Ereference in =
my =

>> ecore model using Eannotaions. I've added the following Eannotation =
to =

>> the Ereference:
>> <eStructuralFeatures xsi:type=3D"ecore:EReference" =

>> name=3D"userAccount" eType=3D"#//Support/UserAccount">
>> <eAnnotations source=3D"teneo.hibernate">
>> <details key=3D"appinfo" =

>> value=3D"@Column(unique=3D&quot;true&quot;)"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> This works fine for an Eattribute, but doesn't seem to have any effe=
ct =

>> on the generated hibernate mappings for an EReference:
>> <many-to-one name=3D"userAccount" entity-name=3D"UserAccount=
" =

>> cascade=3D"merge,persist,save-update,lock,refresh" lazy=3D"false" =

>> insert=3D"true" update=3D"true" not-null=3D"false">
>> <column not-null=3D"false" unique=3D"false" =

>> name=3D"`useraccount_useraccount_id`"/>
>> </many-to-one>
>> I'm still new to fiddling about with the Eannotations, so please =

>> forgive me if this is a dumb question.
>> //Stephen
>
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Previous Topic:[teneo] bidirectional OneToOne containment association - container not set in child object
Next Topic:[Teneo] How to set 'cascade="none"' on many-to-one reference in Hibernate
Goto Forum:
  


Current Time: Sat Feb 27 20:57:08 GMT 2021

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

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

Back to the top