|
Re: [Teneo] OneToMany without join table in orm.xml [message #630576 is a reply to message #630569] |
Mon, 04 October 2010 08:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Peter,
Where did you add the jpa annotations? In the ecore? If so then you need to regenerate the java code for Teneo to pick
up these changes.
Btw (I am not sure if I already mentioned this), but if you want to use EMF/Teneo in a non-rcp environment then it can
be an idea to try the EMFT Texo project (it has some benefits compared to EMF/Teneo in server side environments):
http://wiki.eclipse.org/Texo
http://wiki.eclipse.org/Texo#Code_generation_topics
http://wiki.eclipse.org/Texo#Texo_and_EMF
gr. Martin
On 10/04/2010 10:34 AM, Peter Kullmann wrote:
> Hi, I'm just starting to use teneo with EclipseLink and tried to connect
> my model to an existing legacy database. I have a simple 1:n relation
> where the child table contains a column with the parent key to realize
> the link in the db.
>
> I tried some teneo.jpa annotations to control how the relation is
> translated into the orm.xml but it always gives me the <join-table>
> element as child of <one-to-many>. I've read about
> teneo.mapping.join_table_for_non_contained_associations but how can I
> set this option at "design time", ie when I try to create the orm.xml in
> the context menu of the ecore.
>
> Here's the 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="core"
> nsURI="http:///ch/arenae/projectcontrolling/core.ecore"
> nsPrefix="ch.arenae.projectcontrolling.core">
> <eClassifiers xsi:type="ecore:EClass" name="Rapport">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mitarbeiter"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stundenVerrech"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong">
> <eAnnotations source="teneo.jpa">
> <details key="value"
> value=" @Id
@GeneratedValue
@Column(name="R _ID") "/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="project"
> lowerBound="1"
> eType="#//Project" eOpposite="#//Project/rapporte">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@JoinColumn(name="P_ID")"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Project">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@Table(name="PROJEKTE")"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="rapporte"
> upperBound="-1"
> eType="#//Rapport" eOpposite="#//Rapport/project">
> <eAnnotations source="teneo.jpa">
> <details key="value" value="@OneToMany(unique=true, indexed=false,
> mappedBy="project")"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
>
> And this is the generated orm.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
> http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0">
> <persistence-unit-metadata>
> <xml-mapping-metadata-complete/>
> <persistence-unit-defaults>
> <access>FIELD</access>
> </persistence-unit-defaults>
> </persistence-unit-metadata>
> <entity class="ch.arenae.projectcontrolling.core.impl.RapportImpl"
> name="Rapport">
> <table name="RAPPORT"/>
> <inheritance strategy="JOINED"/>
> <attributes>
> <id name="id">
> <column insertable="true" length="255" name="R_ID" nullable="true"
> precision="0" scale="0" unique="false" updatable="true"/>
> <generated-value strategy="AUTO"/>
> </id>
> <basic fetch="EAGER" name="mitarbeiter" optional="true"/>
> <basic fetch="EAGER" name="stundenVerrech" optional="true"/>
> <basic name="eContainerFeatureID">
> <column name="ECONT_FEAT_ID"/>
> </basic>
> <many-to-one fetch="EAGER" name="project" optional="true"
> target-entity="ch.arenae.projectcontrolling.core.impl.ProjectImpl ">
> <join-column insertable="true" name="P_ID" nullable="true"
> unique="false" updatable="true"/>
> <cascade>
> <cascade-persist/>
> <cascade-merge/>
> <cascade-refresh/>
> </cascade>
> </many-to-one>
> </attributes>
> </entity>
> <entity class="ch.arenae.projectcontrolling.core.impl.ProjectImpl"
> name="Project">
> <table name="PROJEKTE"/>
> <inheritance strategy="JOINED"/>
> <attributes>
> <basic fetch="EAGER" name="id" optional="true"/>
> <basic name="eContainerFeatureID">
> <column name="ECONT_FEAT_ID"/>
> </basic>
> <one-to-many fetch="LAZY" mapped-by="project" name="rapporte"
> target-entity="ch.arenae.projectcontrolling.core.impl.RapportImpl ">
> <join-table name="PROJECT_RAPPORTE">
> <join-column insertable="true" name="PROJECT_E_ID" nullable="false"
> unique="false" updatable="true"/>
> <inverse-join-column insertable="true" name="RAPPORT_ID"
> nullable="false" unique="false" updatable="true"/>
> </join-table>
> <cascade>
> <cascade-persist/>
> <cascade-merge/>
> <cascade-refresh/>
> </cascade>
> </one-to-many>
> </attributes>
> </entity>
> </entity-mappings>
>
> The goal is to create this:
>
> <one-to-many fetch="LAZY" mapped-by="project" name="rapporte"
> target-entity="ch.arenae.projectcontrolling.core.impl.RapportImpl ">
> <join-table name="PROJECT_RAPPORTE">
> </one-to-many>
> (ie, no child elements)
>
>
> Thanks & regards,
> Peter
--
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03299 seconds