Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey
[Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1392145] Tue, 01 July 2014 23:50 Go to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
I am trying to follow this example and create a many to many relation in model in a separate table with composite key and additional columns using Teneo. My model is in hibernate and this is what the ecore file like for the part of model:

<?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="my" nsURI="test.my" nsPrefix="test">
  <eClassifiers xsi:type="ecore:EClass" name="Resource">
    <eAnnotations source="teneo.jpa">
      <details key="appinfo" value="@Table(uniqueConstraints={@UniqueConstraint(columnNames={&quot;ip&quot;,&quot;name&quot;, &quot;revision&quot;,  &quot;type&quot;})})"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
        iD="true">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@Id&#xD;&#xA;    @GeneratedValue(strategy=GenerationType.AUTO)"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="resourceTags" ordered="false"
        upperBound="-1" eType="#//ResourceTag" resolveProxies="false" eOpposite="#//ResourceTag/resource">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@OneToMany ( indexed = false, fetch=FetchType.EAGER, mappedBy = &quot;resourceId&quot;,  cascade=CascadeType.ALL)"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Tag">
    <eAnnotations source="teneo.jpa">
      <details key="appinfo" value="@Table(uniqueConstraints={@UniqueConstraint(columnNames={ &quot;name&quot;})})&#xD;&#xA;@NoAuditing"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
        iD="true">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@Id&#xD;&#xA;    @GeneratedValue(strategy=GenerationType.AUTO)"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="resourceTags" ordered="false"
        upperBound="-1" eType="#//ResourceTag" resolveProxies="false" eOpposite="#//ResourceTag/tag">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@OneToMany (indexed=false, fetch=FetchType.EAGER, mappedBy = &quot;pk.tagid&quot;, cascade=CascadeType.ALL)"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ResourceTag">
    <eAnnotations source="teneo.jpa">
      <details key="appinfo" value="@Table(name = &quot;ResourceTag&quot;)&#xD;&#xA;"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="pk" eType="#//ResourceTagId"
        resolveProxies="false">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@EmbeddedId"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="comment" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="tag" eType="#//Tag" eOpposite="#//Tag/resourceTags">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@Transient"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="resource" eType="#//Resource"
        eOpposite="#//Resource/resourceTags">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@Transient"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ResourceTagId">
    <eAnnotations source="teneo.jpa">
      <details key="appinfo" value="@Embeddable"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="tag" eType="#//Tag">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@ManyToOne&#xD;&#xA;@JoinColumns({&#xD;&#xA;&#x9;@JoinColumn(name=&quot;tagId&quot;, referencedColumnName = &quot;id&quot;)&#xD;&#xA;})"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EReference" name="resource" eType="#//Resource">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@ManyToOne&#xD;&#xA;@JoinColumns({&#xD;&#xA;&#x9;@JoinColumn(name=&quot;resourceId&quot;, referencedColumnName = &quot;id&quot;)&#xD;&#xA;})"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
</ecore:EPackage>




The generated mapping for this model is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="false">
	<typedef name="model.EIllegalStateException" class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
		<param name="epackage">http://www.qualcomm.com/qti/qsip/designbook/model</param>
		<param name="edatatype">EIllegalStateException</param>
	</typedef>
	<class name="test.my.ResourceImpl" entity-name="Resource" abstract="false" lazy="false" discriminator-value="Resource" table="`resource`">
		<meta attribute="eclassName" inherit="false">Resource</meta>
		<meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
		<id name="id" type="int" unsaved-value="0">
			<column not-null="true" unique="false" name="`id`"/>
			<generator class="native"/>
		</id>
		<discriminator type="string">
			<column name="`dtype`" index="resourcedtype" length="255" not-null="true"/>
		</discriminator>
		<version name="revision" type="int">
			<column not-null="true" unique="false" name="`revision`" unique-key="c0"/>
		</version>
		<property name="type" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
			<column not-null="false" unique="false" name="`type`" unique-key="c0"/>
		</property>
		<property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
			<column not-null="false" unique="false" name="`name`" unique-key="c0"/>
		</property>
		<bag name="resourceTags" inverse="true" lazy="false" cascade="all,delete-orphan">
			<key update="true">
				<column name="`resourcetag_resource_id`" unique="false"/>
			</key>
			<one-to-many entity-name="ResourceTag"/>
		</bag>
	</class>
	<class name="test.my.TagImpl" entity-name="Tag" abstract="false" lazy="false" discriminator-value="Tag" table="`tag`">
		<meta attribute="eclassName" inherit="false">Tag</meta>
		<meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
		<id name="id" type="int" unsaved-value="0">
			<column not-null="true" unique="false" name="`id`"/>
			<generator class="native"/>
		</id>
		<discriminator type="string">
			<column name="`dtype`" index="tagdtype" length="255" not-null="true"/>
		</discriminator>
		<property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
			<column not-null="false" unique="false" name="`name`" unique-key="c0"/>
		</property>
		<bag name="resourceTags" inverse="true" lazy="false" cascade="all,delete-orphan">
			<key update="true">
				<column name="`resourcetag_tag_id`" unique="false"/>
			</key>
			<one-to-many entity-name="ResourceTag"/>
		</bag>
	</class>
	<class name="test.my.ResourceTagImpl" entity-name="ResourceTag" abstract="false" lazy="false" discriminator-value="ResourceTag" table="`resourcetag`">
		<meta attribute="eclassName" inherit="false">ResourceTag</meta>
		<meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
		<composite-id name="pk" class="test.my.ResourceTagIdImpl" access="org.eclipse.emf.teneo.hibernate.mapping.property.EReferencePropertyHandler">
			<meta attribute="eclassName" inherit="false">ResourceTagId</meta>
			<meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
			<key-many-to-one name="tag" entity-name="Tag" lazy="false">
				<column not-null="false" unique="false" name="`tagid`"/>
			</key-many-to-one>
			<key-many-to-one name="resource" entity-name="Resource" lazy="false">
				<column not-null="false" unique="false" name="`resourceid`"/>
			</key-many-to-one>
		</composite-id>
		<discriminator type="string">
			<column name="`dtype`" index="ResourceTagdtype" length="255" not-null="true"/>
		</discriminator>
		<property name="date" lazy="false" insert="true" update="true" not-null="false" unique="false" type="timestamp">
			<column not-null="false" unique="false" name="`date`"/>
		</property>
		<property name="comment" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
			<column not-null="false" unique="false" name="`comment`"/>
		</property>
	</class>
</hibernate-mapping>



As you can see the oneToMany mapping from Resource to ResourceTag is mapped by a new foreignkey, as a result of this the ResourceTag table has repeated columns named resourcetag_tag_id and resourcetag_resource_id other than the ones in the composite primary key 'resourceId' and 'tagid'.

My hibernate perisitent options are following:

props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_NON_CONTAINMENT,
                "PERSIST,REFRESH");
props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT,
                "ALL");

props.setProperty(PersistenceOptions.MAP_ALL_LISTS_AS_IDBAG, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "false");

props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY, "false");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_ASSOCIATIONS, "false");
props.setProperty(PersistenceOptions.SET_FOREIGN_KEY_NAME, "false");
props.setProperty(PersistenceOptions.FEATUREMAP_AS_COMPONENT, "true");



I have tried many different combinations in the mappedby attribute of @OnetoMany relation in the resource.resourceTags but all of them are ignored by teneo/hibernate. I also tried to use the @AssociationOverride as explained in the example, but that didn't have any effect on the mapping either.

What I want to achieve a bidirectional many-to-many relation between tag and resource which has some extra attributes. So that, when I loaded the resource I can automatically get the tags and when I load the tag I can automatically get the resources. However, with this mapping the extra foreign key columns in the ResourceTag table are null and the relation doesn't get fetched as a result.

This is a subset of the model and many other references are included in these classes that I removed. Many of the configurations are defined based on teh other requirements.

I posted this question on stackoveflow as well
Re: [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1392643 is a reply to message #1392145] Wed, 02 July 2014 16:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Roza,
Have you tried without mappedBy? As there is an eopposite it is possible that Teneo will detect this automatically.
Another thing you can try is to use a @JoinColumn annotation on the OneToMany side.

gr. Martin

On 02-07-14 01:50, Roza Ghamari wrote:
> I am trying to follow http://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/
> and create a many to many relation in model in a separate table with composite key and additional columns using Teneo.
> My model is in hibernate and this is what the ecore file like for the part of model:
>
> <?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="my" nsURI="test.my" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Resource">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Table(uniqueConstraints={@UniqueConstraint(columnNames={"ip","name", "revision",
> "type"})})"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EInt"
> iD="true">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Id
> @GeneratedValue(strategy=GenerationType.AUTO)"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="resourceTags" ordered="false"
> upperBound="-1" eType="#//ResourceTag" resolveProxies="false" eOpposite="#//ResourceTag/resource">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@OneToMany ( indexed = false, fetch=FetchType.EAGER, mappedBy = "resourceId",
> cascade=CascadeType.ALL)"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Tag">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Table(uniqueConstraints={@UniqueConstraint(columnNames={ "name"})})
> @NoAuditing"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EInt"
> iD="true">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Id
> @GeneratedValue(strategy=GenerationType.AUTO)"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="resourceTags" ordered="false"
> upperBound="-1" eType="#//ResourceTag" resolveProxies="false" eOpposite="#//ResourceTag/tag">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@OneToMany (indexed=false, fetch=FetchType.EAGER, mappedBy = "pk.tagid",
> cascade=CascadeType.ALL)"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="ResourceTag">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Table(name = "ResourceTag")
> "/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="pk" eType="#//ResourceTagId"
> resolveProxies="false">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@EmbeddedId"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="comment" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="tag" eType="#//Tag" eOpposite="#//Tag/resourceTags">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Transient"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="resource" eType="#//Resource"
> eOpposite="#//Resource/resourceTags">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Transient"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="ResourceTagId">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@Embeddable"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EReference" name="tag" eType="#//Tag">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@ManyToOne
> @JoinColumns({
> @JoinColumn(name="tagId", referencedColumnName = "id")
> })"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="resource" eType="#//Resource">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@ManyToOne
> @JoinColumns({
> @JoinColumn(name="resourceId", referencedColumnName = "id")
> })"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
> The generated mapping for this model is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <hibernate-mapping auto-import="false">
> <typedef name="model.EIllegalStateException" class="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType">
> <param name="epackage">http://www.qualcomm.com/qti/qsip/designbook/model</param>
> <param name="edatatype">EIllegalStateException</param>
> </typedef>
> <class name="test.my.ResourceImpl" entity-name="Resource" abstract="false" lazy="false"
> discriminator-value="Resource" table="`resource`">
> <meta attribute="eclassName" inherit="false">Resource</meta>
> <meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
> <id name="id" type="int" unsaved-value="0">
> <column not-null="true" unique="false" name="`id`"/>
> <generator class="native"/>
> </id>
> <discriminator type="string">
> <column name="`dtype`" index="resourcedtype" length="255" not-null="true"/>
> </discriminator>
> <version name="revision" type="int">
> <column not-null="true" unique="false" name="`revision`" unique-key="c0"/>
> </version>
> <property name="type" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.String">
> <column not-null="false" unique="false" name="`type`" unique-key="c0"/>
> </property>
> <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.String">
> <column not-null="false" unique="false" name="`name`" unique-key="c0"/>
> </property>
> <bag name="resourceTags" inverse="true" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="`resourcetag_resource_id`" unique="false"/>
> </key>
> <one-to-many entity-name="ResourceTag"/>
> </bag>
> </class>
> <class name="test.my.TagImpl" entity-name="Tag" abstract="false" lazy="false" discriminator-value="Tag" table="`tag`">
> <meta attribute="eclassName" inherit="false">Tag</meta>
> <meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
> <id name="id" type="int" unsaved-value="0">
> <column not-null="true" unique="false" name="`id`"/>
> <generator class="native"/>
> </id>
> <discriminator type="string">
> <column name="`dtype`" index="tagdtype" length="255" not-null="true"/>
> </discriminator>
> <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.String">
> <column not-null="false" unique="false" name="`name`" unique-key="c0"/>
> </property>
> <bag name="resourceTags" inverse="true" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="`resourcetag_tag_id`" unique="false"/>
> </key>
> <one-to-many entity-name="ResourceTag"/>
> </bag>
> </class>
> <class name="test.my.ResourceTagImpl" entity-name="ResourceTag" abstract="false" lazy="false"
> discriminator-value="ResourceTag" table="`resourcetag`">
> <meta attribute="eclassName" inherit="false">ResourceTag</meta>
> <meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
> <composite-id name="pk" class="test.my.ResourceTagIdImpl"
> access="org.eclipse.emf.teneo.hibernate.mapping.property.EReferencePropertyHandler">
> <meta attribute="eclassName" inherit="false">ResourceTagId</meta>
> <meta attribute="epackage" inherit="false">http://www.qualcomm.com/qti/qsip/designbook/model</meta>
> <key-many-to-one name="tag" entity-name="Tag" lazy="false">
> <column not-null="false" unique="false" name="`tagid`"/>
> </key-many-to-one>
> <key-many-to-one name="resource" entity-name="Resource" lazy="false">
> <column not-null="false" unique="false" name="`resourceid`"/>
> </key-many-to-one>
> </composite-id>
> <discriminator type="string">
> <column name="`dtype`" index="ResourceTagdtype" length="255" not-null="true"/>
> </discriminator>
> <property name="date" lazy="false" insert="true" update="true" not-null="false" unique="false" type="timestamp">
> <column not-null="false" unique="false" name="`date`"/>
> </property>
> <property name="comment" lazy="false" insert="true" update="true" not-null="false" unique="false"
> type="java.lang.String">
> <column not-null="false" unique="false" name="`comment`"/>
> </property>
> </class>
> </hibernate-mapping>
>
>
> As you can see the oneToMany mapping from Resource to ResourceTag is mapped by a new foreignkey, as a result of this the
> ResourceTag table has repeated columns named resourcetag_tag_id and resourcetag_resource_id other than the ones in the
> composite primary key 'resourceId' and 'tagid'.
>
> My hibernate perisitent options are following:
>
> props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_NON_CONTAINMENT,
> "PERSIST,REFRESH");
> props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT,
> "ALL");
>
> props.setProperty(PersistenceOptions.MAP_ALL_LISTS_AS_IDBAG, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "false");
>
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_KEY, "false");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.JOIN_TABLE_FOR_NON_CONTAINED_ASSOCIATIONS, "false");
> props.setProperty(PersistenceOptions.SET_FOREIGN_KEY_NAME, "false");
> props.setProperty(PersistenceOptions.FEATUREMAP_AS_COMPONENT, "true");
>
>
> I have tried many different combinations in the mappedby attribute of @OnetoMany relation in the resource.resourceTags
> but all of them are ignored by teneo/hibernate. I also tried to use the @AssociationOverride as explained in the
> example, but that didn't have any effect on the mapping either.
>
> What I want to achieve a bidirectional many-to-many relation between tag and resource which has some extra attributes.
> So that, when I loaded the resource I can automatically get the tags and when I load the tag I can automatically get the
> resources. However, with this mapping the extra foreign key columns in the ResourceTag table are null and the relation
> doesn't get fetched as a result.
>
> This is a subset of the model and many other references are included in these classes that I removed. Many of the
> configurations are defined based on teh other requirements.
>
> I posted this question on
> http://stackoverflow.com/questions/24520714/teneo-ignores-mappedby-in-onetomany-and-created-foreignkey as well


--

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
Re: [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1392870 is a reply to message #1392643] Thu, 03 July 2014 00:10 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
It is same without mappedBy as well. The problem is the eOpposite references in ResourceTag need to be transient because they are actually provided by ResourceTagId as composite primary key.

I was not using joincolumn because it seemed to be the attribute of ReosurceTag but actually I just tried it and it worked. Thank you very much for your help.
Re: [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1393054 is a reply to message #1392870] Thu, 03 July 2014 07:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
A variant, in my experience/work I never needed a composite id (not saying that you don't need it btw.) So for the join
table ResourceTag, do you need to model it explicitly? Would it be an possible for your bus.case to let Hibernate create
and manage it for you?

gr. Martin

On 03-07-14 02:10, Roza Ghamari wrote:
> It is same without mappedBy as well. The problem is the eOpposite references in ResourceTag need to be transient because
> they are actually provided by ResourceTagId as composite primary key.
> I was not using joincolumn because it seemed to be the attribute of ReosurceTag but actually I just tried it and it
> worked. Thank you very much for your help.


--

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
Re: [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1393439 is a reply to message #1393054] Thu, 03 July 2014 20:07 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
The nm relation between Resource and Tag has extra attributes, like date, or creator. That's why the model is needed explicitly. And this was the only way I found to define it.
Re: [Teneo] Teneo ignores mappedBy in OneToMany and created ForeignKey [message #1393470 is a reply to message #1393439] Thu, 03 July 2014 21:16 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi, even then I would give it its own id, and not use composite-id in combination with mapped-by (makes it more
complex), can you try if that helps here?

gr. Martin

On 03-07-14 22:07, Roza Ghamari wrote:
> The nm relation between Resource and Tag has extra attributes, like date, or creator. That's why the model is needed
> explicitly. And this was the only way I found to define it.


--

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:[ECP] How to properly extend EMFStoreUIProvider
Next Topic:Ecore Diagram: Reactivate Attribute
Goto Forum:
  


Current Time: Tue Mar 09 11:31:58 GMT 2021

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

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

Back to the top