Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: @OneToOne bidirectional association using primary key
Re: @OneToOne bidirectional association using primary key [message #420101] Wed, 18 June 2008 03:45
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030500080506040700050604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Krasimir,
I have a testcase with a one-to-one which creates one column on one side
(the head table will have a person column). I don't use the
PrimaryKeyJoinColumn explicitly. Afaics it is correct that one side is
mapped as a mto (with unique=true). See the attached ecore for an example.

I have cross-posted to the emf newsgroup as then other people can
possibly use this information.

Let me know if this answers your question.

gr. Martin

Krasimir Chobantonov wrote:
> Hi Martin,
>
> Before opening a new bug/improvement for Teneo I wanted to check with you if currently the Teneo project supports bidirectional one-to-one assiciation on a primary key ( http://www.hibernate.org/hib_docs/reference/en/html/associat ions.html#assoc-bidirectional-121)
>
> I've tried different combinations with the annotations but I always get the one-to-one element only in one of the entities and the other entity is always using many-to-one and because of that it is generation additional column.
>
> Am I doing something wrong or the Teneo currently does not support that ?
>
> P.S.
> On one side of the one-to-one relationship I'm using @OneToOne annotation and on the other side I'm using the @OneToOne annotation with the mappedBy attribute along with the @PrimaryKeyJoinColumn annotation.
>
> Krasimir
>
>
>
>
>
>

--

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


--------------030500080506040700050604
Content-Type: text/xml;
name="toone.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="toone.ecore"

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="toone"
nsURI=" http://www.eclipse.org/emf/teneo/samples/emf/annotations/too ne" nsPrefix="toone">
<eClassifiers xsi:type="ecore:EClass" name="Address">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Address"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="city" unique="false" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="city"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Arm">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Arm"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="length" unique="false"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Int"
unsettable="true">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="length"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Head">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Head"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="hairColor" unique="false"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="hairColor"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="person" lowerBound="1"
eType="#//Person" resolveProxies="false" eOpposite="#//Person/head">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value=" &#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&# x9;@OneToOne(fetch=EAGER cascade={MERGE,PERSIST,REFRESH} targetEntity=&quot;Person&quot; optional=false mappedBy=&quot;head&quot;)&#xA;&#x9;&#x9 ;&#x9;&#x9;&#x9; "/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="person"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Person">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Person"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="address" eType="#//Address"
resolveProxies="false">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@ManyToOne(fetch=EAGER cascade={MERGE,PERSIST,REFRESH} targetEntity=&quot;Address&quot; optional=true)"/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="address"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="head" eType="#//Head" resolveProxies="false"
eOpposite="#//Head/person">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@OneToOne(fetch=EAGER cascade=ALL targetEntity=&quot;Head&quot; optional=true)"/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="head"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="leftArm" lowerBound="1"
eType="#//Arm" resolveProxies="false">
<eAnnotations source="teneo.jpa">
<details key="appinfo" value="@OneToOne(fetch=EAGER cascade=NONE targetEntity=&quot;Arm&quot; optional=true)"/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="leftArm"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>

--------------030500080506040700050604--
Previous Topic:[CDO] how to create a IConnector?
Next Topic:CDO server setup
Goto Forum:
  


Current Time: Sun Sep 22 08:56:52 GMT 2024

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

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

Back to the top