Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Texo] Modeling a OneToOne relationship
[Texo] Modeling a OneToOne relationship [message #1244027] Tue, 11 February 2014 20:22 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 211
Registered: July 2009
Senior Member
Hi all,
I've tried to model a one-to-one relationship without success. At first,
the business background :-)

I've Document which has a Contact referenced (only one!). This should
result to

@Entity()
public class Document implements Serializable {
   // some other attributes

   @OneToOne(cascade = { CascadeType.ALL })
   private Contact contact = null;
}


The model looks like following (AnnotationModel):

<annotatedEStructuralFeatures
xsi:type="annotationsmodel:AnnotatedEReference">
        <eReference href="MyEcore.ecore#//Document/contact"/>
        <eReferenceAnnotations
xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contact"
getter="getContact" defaultValue="null" setter="setContact"
validJavaMemberName="contact" useList="false"
ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.11/@eClassAnnotations.0"
generateSafeManyAccess="false"
generateBidirectionalAssociationSupport="false"/>
        <eReferenceAnnotations
xsi:type="ormannotations:EReferenceORMAnnotation">
          <joinColumn name="FK_CONTACT" nullable="true" table=""/>
          <oneToOne/>
        </eReferenceAnnotations>
</annotatedEStructuralFeatures>


Ecore:
    <eStructuralFeatures xsi:type="ecore:EReference" name="contact"
eType="#//Contact" containment="true"/>


However, the generated has a @ManyToOne annotation for contact. How can
I get this right?

TIA,
Ralf.
Re: [Texo] Modeling a OneToOne relationship [message #1250434 is a reply to message #1244027] Wed, 19 February 2014 08:39 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hey Ralf,
I am on holiday therefore the slower than usual answer...

Texo will generate a many-to-one if there is no opposite ereference from Contact to Document, or if this opposite
ereference has many=true.

Is that the case here?

gr. Martin

On 02/11/2014 09:22 PM, Ralf Heydenreich wrote:
> Hi all,
> I've tried to model a one-to-one relationship without success. At first,
> the business background :-)
>
> I've Document which has a Contact referenced (only one!). This should
> result to
>
>
> @Entity()
> public class Document implements Serializable {
>     // some other attributes
>
>     @OneToOne(cascade = { CascadeType.ALL })
>     private Contact contact = null;
> }
> 

>
> The model looks like following (AnnotationModel):
>
>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEReference">
>          <eReference href="MyEcore.ecore#//Document/contact"/>
>          <eReferenceAnnotations
> xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contact"
> getter="getContact" defaultValue="null" setter="setContact"
> validJavaMemberName="contact" useList="false"
> ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.11/@eClassAnnotations.0"
> generateSafeManyAccess="false"
> generateBidirectionalAssociationSupport="false"/>
>          <eReferenceAnnotations
> xsi:type="ormannotations:EReferenceORMAnnotation">
>            <joinColumn name="FK_CONTACT" nullable="true" table=""/>
>            <oneToOne/>
>          </eReferenceAnnotations>
> </annotatedEStructuralFeatures>
> 

>
> Ecore:
>
>      <eStructuralFeatures xsi:type="ecore:EReference" name="contact"
> eType="#//Contact" containment="true"/>
> 

>
> However, the generated has a @ManyToOne annotation for contact. How can
> I get this right?
>
> TIA,
> Ralf.
>


--

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:[Xcore] problems with &quot;Converting a GenModel to an Xcore Model&quot;
Next Topic:"Generate All" from a genmodel located in a git repository
Goto Forum:
  


Current Time: Mon Dec 09 21:51:41 GMT 2019

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

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

Back to the top