Home » Modeling » EMF » [CDO] Hibernate store mapping issue
|
Re: [CDO] Hibernate store mapping issue [message #768185 is a reply to message #768162] |
Mon, 19 December 2011 17:57 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Yes just one side of a bi-directional association is represented in the database. Teneo uses a specific mechanism to
decide on which side of the bi-directional association the fk should be. It uses alphabetical ordering. This is needed
because Teneo needs to make the same choice consistently. I guess that is the reason that the 2 associations are mapped
in different directions.
But this does not explain the null value you get when retrieving the object. It seems that the database is not filled
with the correct values, can you check the content of the table and see if the OperationOutput column to InvokeOperation
has a value?
Can you post the relevant part of the hbm?
http://wiki.eclipse.org/CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping
http://wiki.eclipse.org/CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging
gr. Martin
On 12/19/2011 06:22 PM, Dan Pollitt wrote:
> Hi all (Martin..),
>
> I'm seeing an issue in the OR mapping that has occurred where two references of a class are being handled quite
> differently.
>
> Extract of model I'm using:
>
> ...
> <eClassifiers xsi:type="ecore:EClass" name="InvokeOperation" eSuperTypes="#//Action">
> ...
> <eStructuralFeatures xsi:type="ecore:EReference" name="input" eType="#//OperationInput"
> containment="true" eOpposite="#//OperationInput/invokeOperation"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="output" eType="#//OperationOutput"
> containment="true" eOpposite="#//OperationOutput/invokeOperation"/>
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EClass" name="OperationOutput">
> <eStructuralFeatures xsi:type="ecore:EReference" name="invokeOperation" eType="#//InvokeOperation"
> eOpposite="#//InvokeOperation/output"/>
> ...
> </eClassifiers>
>
> <eClassifiers xsi:type="ecore:EClass" name="OperationInput">
> <eStructuralFeatures xsi:type="ecore:EReference" name="invokeOperation" eType="#//InvokeOperation"
> eOpposite="#//InvokeOperation/input"/>
> ...
> </eClassifiers>
> ...
>
> The issue I'm seeing is that the input and output references of InvokeOperation are being mapped quite differently,
> input is a foreign key column in an InvokeOperation table but output is not, the OperationOutput table has a foreign key
> back to InvokeOperation but the OperationInput table does not. A guess is just one side of the bidirectional
> relationship is represented in the database?
>
> In my application code I create instances of the OperationInput and OperationOutput and set them on the InvokeOperation.
> This is fine for the duration of the CDO Server being up but if I restart the server and then retrieve my
> InvokeOperation instance then the InvokeOperation#getOutput() returns null.
>
> Is there som mapping help I should be providing here to ensure consistency or perhaps something peculiar to it being a
> bidirectional reference?
>
>
> Thanks,
> Dan
--
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
|
|
|
Re: [CDO] Hibernate store mapping issue [message #768499 is a reply to message #768185] |
Tue, 20 December 2011 09:03 |
Dan Pollitt Messages: 55 Registered: August 2010 |
Member |
|
|
Hi Martin,
Yes I checked in the DB and the invokeOperation column of the
operationoutput table contains a null value.
I generated the hibernate mapping as you referenced and the sections of
the result relating to InvokeOperation, OperationInput and
OperationOutput are below:
== generated_hbm.xml ==
<class entity-name="OperationOutput" abstract="false" lazy="true"
table="`operationoutput`">
<meta attribute="eclassName" inherit="false">OperationOutput</meta>
<meta attribute="epackage"
inherit="false">http://www.example.com/2011/11/tester</meta>
<tuplizer entity-mode="pojo"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<tuplizer entity-mode="dynamic-map"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<id type="long" name="idcol" column="idcol"
access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
<meta attribute="syntheticId" inherit="false">true</meta>
<generator class="native" />
</id>
<property name="resourceID"
type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
<column name="resource_id" />
</property>
<property name="containerID" type="string">
<column name="container_id" />
</property>
<property name="version" type="java.lang.Integer">
<meta attribute="version">true</meta>
<column name="version" />
</property>
<many-to-one name="invokeOperation" entity-name="InvokeOperation"
cascade="merge,persist,save-update,lock" not-null="false" lazy="false"
insert="true" update="true" />
<many-to-one name="assertions" entity-name="HasAssertions"
lazy="false" cascade="all" foreign-key="operationoutput_assertions"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false"
name="`hasassertions_assertions_e_id`"
index="OperationOutput_assertions" />
</many-to-one>
<many-to-one name="storeRules" entity-name="HasStoreRules"
lazy="false" cascade="all" foreign-key="operationoutput_storerules"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false"
name="`hasstorerules_storerules_e_id`"
index="OperationOutput_storeRules" />
</many-to-one>
</class>
<class entity-name="OperationInput" abstract="false" lazy="true"
table="`operationinput`">
<meta attribute="eclassName" inherit="false">OperationInput</meta>
<meta attribute="epackage"
inherit="false">http://www.example.com/2011/11/tester</meta>
<tuplizer entity-mode="pojo"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<tuplizer entity-mode="dynamic-map"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<id type="long" name="idcol" column="idcol"
access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
<meta attribute="syntheticId" inherit="false">true</meta>
<generator class="native" />
</id>
<property name="resourceID"
type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
<column name="resource_id" />
</property>
<property name="containerID" type="string">
<column name="container_id" />
</property>
<property name="version" type="java.lang.Integer">
<meta attribute="version">true</meta>
<column name="version" />
</property>
<one-to-one name="invokeOperation" entity-name="InvokeOperation"
cascade="merge,persist,save-update,lock" lazy="false"
property-ref="input" />
<many-to-one name="values" entity-name="HasValues" lazy="false"
cascade="all" foreign-key="operationinput_values" insert="true"
update="true" not-null="false">
<column not-null="false" unique="false" name="`hasvalues_values_e_id`"
index="OperationInput_values" />
</many-to-one>
<many-to-one name="storeRules" entity-name="HasStoreRules"
lazy="false" cascade="all" foreign-key="operationinput_storerules"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false"
name="`hasstorerules_storerules_e_id`"
index="OperationInput_storeRules" />
</many-to-one>
</class>
<joined-subclass entity-name="InvokeOperation"
abstract="false" lazy="true" extends="Action" table="`invokeoperation`">
<meta attribute="eclassName" inherit="false">InvokeOperation</meta>
<meta attribute="epackage"
inherit="false">http://www.example.com/2011/11/tester</meta>
<tuplizer entity-mode="pojo"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<tuplizer entity-mode="dynamic-map"
class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
/>
<key>
<column name="`action_e_id`" />
</key>
<many-to-one name="operation" entity-name="Operation"
lazy="false" cascade="merge,persist,save-update,lock"
foreign-key="invokeoperation_operation"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false" name="`operation_operation_e_id`"
index="InvokeOperation_operation" />
</many-to-one>
<many-to-one name="input" entity-name="OperationInput"
cascade="all" not-null="false" lazy="false" insert="true"
update="true" />
<one-to-one name="output" entity-name="OperationOutput"
cascade="all" lazy="false" property-ref="invokeOperation" />
</joined-subclass>
=======================
I'm not sure if that gives us any pointers?
Thanks,
Dan
On 19/12/2011 17:57, Martin Taal wrote:
> Yes just one side of a bi-directional association is represented in the
> database. Teneo uses a specific mechanism to decide on which side of the
> bi-directional association the fk should be. It uses alphabetical
> ordering. This is needed because Teneo needs to make the same choice
> consistently. I guess that is the reason that the 2 associations are
> mapped in different directions.
>
> But this does not explain the null value you get when retrieving the
> object. It seems that the database is not filled with the correct
> values, can you check the content of the table and see if the
> OperationOutput column to InvokeOperation has a value?
>
> Can you post the relevant part of the hbm?
> http://wiki.eclipse.org/CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping
>
>
> http://wiki.eclipse.org/CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging
>
>
> gr. Martin
>
> On 12/19/2011 06:22 PM, Dan Pollitt wrote:
>> Hi all (Martin..),
>>
>> I'm seeing an issue in the OR mapping that has occurred where two
>> references of a class are being handled quite
>> differently.
>>
>> Extract of model I'm using:
>>
>> ...
>> <eClassifiers xsi:type="ecore:EClass" name="InvokeOperation"
>> eSuperTypes="#//Action">
>> ...
>> <eStructuralFeatures xsi:type="ecore:EReference" name="input"
>> eType="#//OperationInput"
>> containment="true" eOpposite="#//OperationInput/invokeOperation"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="output"
>> eType="#//OperationOutput"
>> containment="true" eOpposite="#//OperationOutput/invokeOperation"/>
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EClass" name="OperationOutput">
>> <eStructuralFeatures xsi:type="ecore:EReference"
>> name="invokeOperation" eType="#//InvokeOperation"
>> eOpposite="#//InvokeOperation/output"/>
>> ...
>> </eClassifiers>
>>
>> <eClassifiers xsi:type="ecore:EClass" name="OperationInput">
>> <eStructuralFeatures xsi:type="ecore:EReference"
>> name="invokeOperation" eType="#//InvokeOperation"
>> eOpposite="#//InvokeOperation/input"/>
>> ...
>> </eClassifiers>
>> ...
>>
>> The issue I'm seeing is that the input and output references of
>> InvokeOperation are being mapped quite differently,
>> input is a foreign key column in an InvokeOperation table but output
>> is not, the OperationOutput table has a foreign key
>> back to InvokeOperation but the OperationInput table does not. A guess
>> is just one side of the bidirectional
>> relationship is represented in the database?
>>
>> In my application code I create instances of the OperationInput and
>> OperationOutput and set them on the InvokeOperation.
>> This is fine for the duration of the CDO Server being up but if I
>> restart the server and then retrieve my
>> InvokeOperation instance then the InvokeOperation#getOutput() returns
>> null.
>>
>> Is there som mapping help I should be providing here to ensure
>> consistency or perhaps something peculiar to it being a
>> bidirectional reference?
>>
>>
>> Thanks,
>> Dan
>
>
|
|
|
Re: [CDO] Hibernate store mapping issue [message #768502 is a reply to message #768499] |
Tue, 20 December 2011 09:11 |
Dan Pollitt Messages: 55 Registered: August 2010 |
Member |
|
|
I've just checked and it doesn't matter which side of the bidirectional
relationship I set in client code, the invokeOperation column in the
OperationOutput table remains null.
Dan
On 20/12/2011 09:03, Dan Pollitt wrote:
> Hi Martin,
>
> Yes I checked in the DB and the invokeOperation column of the
> operationoutput table contains a null value.
>
> I generated the hibernate mapping as you referenced and the sections of
> the result relating to InvokeOperation, OperationInput and
> OperationOutput are below:
>
> == generated_hbm.xml ==
>
> <class entity-name="OperationOutput" abstract="false" lazy="true"
> table="`operationoutput`">
> <meta attribute="eclassName" inherit="false">OperationOutput</meta>
> <meta attribute="epackage"
> inherit="false">http://www.example.com/2011/11/tester</meta>
> <tuplizer entity-mode="pojo"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <tuplizer entity-mode="dynamic-map"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <id type="long" name="idcol" column="idcol"
> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>
> <meta attribute="syntheticId" inherit="false">true</meta>
> <generator class="native" />
> </id>
> <property name="resourceID"
> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>
> <column name="resource_id" />
> </property>
> <property name="containerID" type="string">
> <column name="container_id" />
> </property>
> <property name="version" type="java.lang.Integer">
> <meta attribute="version">true</meta>
> <column name="version" />
> </property>
> <many-to-one name="invokeOperation" entity-name="InvokeOperation"
> cascade="merge,persist,save-update,lock" not-null="false" lazy="false"
> insert="true" update="true" />
> <many-to-one name="assertions" entity-name="HasAssertions"
> lazy="false" cascade="all" foreign-key="operationoutput_assertions"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`hasassertions_assertions_e_id`"
> index="OperationOutput_assertions" />
> </many-to-one>
> <many-to-one name="storeRules" entity-name="HasStoreRules"
> lazy="false" cascade="all" foreign-key="operationoutput_storerules"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`hasstorerules_storerules_e_id`"
> index="OperationOutput_storeRules" />
> </many-to-one>
> </class>
> <class entity-name="OperationInput" abstract="false" lazy="true"
> table="`operationinput`">
> <meta attribute="eclassName" inherit="false">OperationInput</meta>
> <meta attribute="epackage"
> inherit="false">http://www.example.com/2011/11/tester</meta>
> <tuplizer entity-mode="pojo"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <tuplizer entity-mode="dynamic-map"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <id type="long" name="idcol" column="idcol"
> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>
> <meta attribute="syntheticId" inherit="false">true</meta>
> <generator class="native" />
> </id>
> <property name="resourceID"
> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>
> <column name="resource_id" />
> </property>
> <property name="containerID" type="string">
> <column name="container_id" />
> </property>
> <property name="version" type="java.lang.Integer">
> <meta attribute="version">true</meta>
> <column name="version" />
> </property>
> <one-to-one name="invokeOperation" entity-name="InvokeOperation"
> cascade="merge,persist,save-update,lock" lazy="false"
> property-ref="input" />
> <many-to-one name="values" entity-name="HasValues" lazy="false"
> cascade="all" foreign-key="operationinput_values" insert="true"
> update="true" not-null="false">
> <column not-null="false" unique="false" name="`hasvalues_values_e_id`"
> index="OperationInput_values" />
> </many-to-one>
> <many-to-one name="storeRules" entity-name="HasStoreRules"
> lazy="false" cascade="all" foreign-key="operationinput_storerules"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`hasstorerules_storerules_e_id`" index="OperationInput_storeRules" />
> </many-to-one>
> </class>
> <joined-subclass entity-name="InvokeOperation"
> abstract="false" lazy="true" extends="Action" table="`invokeoperation`">
> <meta attribute="eclassName" inherit="false">InvokeOperation</meta>
> <meta attribute="epackage"
> inherit="false">http://www.example.com/2011/11/tester</meta>
> <tuplizer entity-mode="pojo"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <tuplizer entity-mode="dynamic-map"
> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
> />
> <key>
> <column name="`action_e_id`" />
> </key>
> <many-to-one name="operation" entity-name="Operation"
> lazy="false" cascade="merge,persist,save-update,lock"
> foreign-key="invokeoperation_operation"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false" name="`operation_operation_e_id`"
> index="InvokeOperation_operation" />
> </many-to-one>
> <many-to-one name="input" entity-name="OperationInput"
> cascade="all" not-null="false" lazy="false" insert="true" update="true" />
> <one-to-one name="output" entity-name="OperationOutput"
> cascade="all" lazy="false" property-ref="invokeOperation" />
> </joined-subclass>
>
> =======================
>
> I'm not sure if that gives us any pointers?
>
>
> Thanks,
> Dan
>
> On 19/12/2011 17:57, Martin Taal wrote:
>> Yes just one side of a bi-directional association is represented in the
>> database. Teneo uses a specific mechanism to decide on which side of the
>> bi-directional association the fk should be. It uses alphabetical
>> ordering. This is needed because Teneo needs to make the same choice
>> consistently. I guess that is the reason that the 2 associations are
>> mapped in different directions.
>>
>> But this does not explain the null value you get when retrieving the
>> object. It seems that the database is not filled with the correct
>> values, can you check the content of the table and see if the
>> OperationOutput column to InvokeOperation has a value?
>>
>> Can you post the relevant part of the hbm?
>> http://wiki.eclipse.org/CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping
>>
>>
>>
>> http://wiki.eclipse.org/CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging
>>
>>
>>
>> gr. Martin
>>
>> On 12/19/2011 06:22 PM, Dan Pollitt wrote:
>>> Hi all (Martin..),
>>>
>>> I'm seeing an issue in the OR mapping that has occurred where two
>>> references of a class are being handled quite
>>> differently.
>>>
>>> Extract of model I'm using:
>>>
>>> ...
>>> <eClassifiers xsi:type="ecore:EClass" name="InvokeOperation"
>>> eSuperTypes="#//Action">
>>> ...
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="input"
>>> eType="#//OperationInput"
>>> containment="true" eOpposite="#//OperationInput/invokeOperation"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="output"
>>> eType="#//OperationOutput"
>>> containment="true" eOpposite="#//OperationOutput/invokeOperation"/>
>>> </eClassifiers>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="OperationOutput">
>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>> name="invokeOperation" eType="#//InvokeOperation"
>>> eOpposite="#//InvokeOperation/output"/>
>>> ...
>>> </eClassifiers>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="OperationInput">
>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>> name="invokeOperation" eType="#//InvokeOperation"
>>> eOpposite="#//InvokeOperation/input"/>
>>> ...
>>> </eClassifiers>
>>> ...
>>>
>>> The issue I'm seeing is that the input and output references of
>>> InvokeOperation are being mapped quite differently,
>>> input is a foreign key column in an InvokeOperation table but output
>>> is not, the OperationOutput table has a foreign key
>>> back to InvokeOperation but the OperationInput table does not. A guess
>>> is just one side of the bidirectional
>>> relationship is represented in the database?
>>>
>>> In my application code I create instances of the OperationInput and
>>> OperationOutput and set them on the InvokeOperation.
>>> This is fine for the duration of the CDO Server being up but if I
>>> restart the server and then retrieve my
>>> InvokeOperation instance then the InvokeOperation#getOutput() returns
>>> null.
>>>
>>> Is there som mapping help I should be providing here to ensure
>>> consistency or perhaps something peculiar to it being a
>>> bidirectional reference?
>>>
>>>
>>> Thanks,
>>> Dan
>>
>>
>
|
|
|
Re: [CDO] Hibernate store mapping issue [message #768525 is a reply to message #768502] |
Tue, 20 December 2011 10:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hmm, I checked the mappings/model but I have no idea what happens here, can you enter a bugzilla for this (mapping of 2
bidirectional containment associations is done differently)? I am not sure if your model is very large or if I can use
it as an example in the testcases. I can try to replicate the issue in a small model, afaics it should be doable.
gr. Martin
On 12/20/2011 10:11 AM, Dan Pollitt wrote:
> I've just checked and it doesn't matter which side of the bidirectional relationship I set in client code, the
> invokeOperation column in the OperationOutput table remains null.
>
> Dan
>
> On 20/12/2011 09:03, Dan Pollitt wrote:
>> Hi Martin,
>>
>> Yes I checked in the DB and the invokeOperation column of the
>> operationoutput table contains a null value.
>>
>> I generated the hibernate mapping as you referenced and the sections of
>> the result relating to InvokeOperation, OperationInput and
>> OperationOutput are below:
>>
>> == generated_hbm.xml ==
>>
>> <class entity-name="OperationOutput" abstract="false" lazy="true"
>> table="`operationoutput`">
>> <meta attribute="eclassName" inherit="false">OperationOutput</meta>
>> <meta attribute="epackage"
>> inherit="false">http://www.example.com/2011/11/tester</meta>
>> <tuplizer entity-mode="pojo"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <tuplizer entity-mode="dynamic-map"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <id type="long" name="idcol" column="idcol"
>> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>>
>> <meta attribute="syntheticId" inherit="false">true</meta>
>> <generator class="native" />
>> </id>
>> <property name="resourceID"
>> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>>
>> <column name="resource_id" />
>> </property>
>> <property name="containerID" type="string">
>> <column name="container_id" />
>> </property>
>> <property name="version" type="java.lang.Integer">
>> <meta attribute="version">true</meta>
>> <column name="version" />
>> </property>
>> <many-to-one name="invokeOperation" entity-name="InvokeOperation"
>> cascade="merge,persist,save-update,lock" not-null="false" lazy="false"
>> insert="true" update="true" />
>> <many-to-one name="assertions" entity-name="HasAssertions"
>> lazy="false" cascade="all" foreign-key="operationoutput_assertions"
>> insert="true" update="true" not-null="false">
>> <column not-null="false" unique="false"
>> name="`hasassertions_assertions_e_id`"
>> index="OperationOutput_assertions" />
>> </many-to-one>
>> <many-to-one name="storeRules" entity-name="HasStoreRules"
>> lazy="false" cascade="all" foreign-key="operationoutput_storerules"
>> insert="true" update="true" not-null="false">
>> <column not-null="false" unique="false"
>> name="`hasstorerules_storerules_e_id`"
>> index="OperationOutput_storeRules" />
>> </many-to-one>
>> </class>
>> <class entity-name="OperationInput" abstract="false" lazy="true"
>> table="`operationinput`">
>> <meta attribute="eclassName" inherit="false">OperationInput</meta>
>> <meta attribute="epackage"
>> inherit="false">http://www.example.com/2011/11/tester</meta>
>> <tuplizer entity-mode="pojo"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <tuplizer entity-mode="dynamic-map"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <id type="long" name="idcol" column="idcol"
>> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>>
>> <meta attribute="syntheticId" inherit="false">true</meta>
>> <generator class="native" />
>> </id>
>> <property name="resourceID"
>> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>>
>> <column name="resource_id" />
>> </property>
>> <property name="containerID" type="string">
>> <column name="container_id" />
>> </property>
>> <property name="version" type="java.lang.Integer">
>> <meta attribute="version">true</meta>
>> <column name="version" />
>> </property>
>> <one-to-one name="invokeOperation" entity-name="InvokeOperation"
>> cascade="merge,persist,save-update,lock" lazy="false"
>> property-ref="input" />
>> <many-to-one name="values" entity-name="HasValues" lazy="false"
>> cascade="all" foreign-key="operationinput_values" insert="true"
>> update="true" not-null="false">
>> <column not-null="false" unique="false" name="`hasvalues_values_e_id`"
>> index="OperationInput_values" />
>> </many-to-one>
>> <many-to-one name="storeRules" entity-name="HasStoreRules"
>> lazy="false" cascade="all" foreign-key="operationinput_storerules"
>> insert="true" update="true" not-null="false">
>> <column not-null="false" unique="false"
>> name="`hasstorerules_storerules_e_id`" index="OperationInput_storeRules" />
>> </many-to-one>
>> </class>
>> <joined-subclass entity-name="InvokeOperation"
>> abstract="false" lazy="true" extends="Action" table="`invokeoperation`">
>> <meta attribute="eclassName" inherit="false">InvokeOperation</meta>
>> <meta attribute="epackage"
>> inherit="false">http://www.example.com/2011/11/tester</meta>
>> <tuplizer entity-mode="pojo"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <tuplizer entity-mode="dynamic-map"
>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>> />
>> <key>
>> <column name="`action_e_id`" />
>> </key>
>> <many-to-one name="operation" entity-name="Operation"
>> lazy="false" cascade="merge,persist,save-update,lock"
>> foreign-key="invokeoperation_operation"
>> insert="true" update="true" not-null="false">
>> <column not-null="false" unique="false" name="`operation_operation_e_id`"
>> index="InvokeOperation_operation" />
>> </many-to-one>
>> <many-to-one name="input" entity-name="OperationInput"
>> cascade="all" not-null="false" lazy="false" insert="true" update="true" />
>> <one-to-one name="output" entity-name="OperationOutput"
>> cascade="all" lazy="false" property-ref="invokeOperation" />
>> </joined-subclass>
>>
>> =======================
>>
>> I'm not sure if that gives us any pointers?
>>
>>
>> Thanks,
>> Dan
>>
>> On 19/12/2011 17:57, Martin Taal wrote:
>>> Yes just one side of a bi-directional association is represented in the
>>> database. Teneo uses a specific mechanism to decide on which side of the
>>> bi-directional association the fk should be. It uses alphabetical
>>> ordering. This is needed because Teneo needs to make the same choice
>>> consistently. I guess that is the reason that the 2 associations are
>>> mapped in different directions.
>>>
>>> But this does not explain the null value you get when retrieving the
>>> object. It seems that the database is not filled with the correct
>>> values, can you check the content of the table and see if the
>>> OperationOutput column to InvokeOperation has a value?
>>>
>>> Can you post the relevant part of the hbm?
>>> http://wiki.eclipse.org/CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping
>>>
>>>
>>>
>>>
>>> http://wiki.eclipse.org/CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging
>>>
>>>
>>>
>>> gr. Martin
>>>
>>> On 12/19/2011 06:22 PM, Dan Pollitt wrote:
>>>> Hi all (Martin..),
>>>>
>>>> I'm seeing an issue in the OR mapping that has occurred where two
>>>> references of a class are being handled quite
>>>> differently.
>>>>
>>>> Extract of model I'm using:
>>>>
>>>> ...
>>>> <eClassifiers xsi:type="ecore:EClass" name="InvokeOperation"
>>>> eSuperTypes="#//Action">
>>>> ...
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="input"
>>>> eType="#//OperationInput"
>>>> containment="true" eOpposite="#//OperationInput/invokeOperation"/>
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="output"
>>>> eType="#//OperationOutput"
>>>> containment="true" eOpposite="#//OperationOutput/invokeOperation"/>
>>>> </eClassifiers>
>>>>
>>>> <eClassifiers xsi:type="ecore:EClass" name="OperationOutput">
>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>> name="invokeOperation" eType="#//InvokeOperation"
>>>> eOpposite="#//InvokeOperation/output"/>
>>>> ...
>>>> </eClassifiers>
>>>>
>>>> <eClassifiers xsi:type="ecore:EClass" name="OperationInput">
>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>> name="invokeOperation" eType="#//InvokeOperation"
>>>> eOpposite="#//InvokeOperation/input"/>
>>>> ...
>>>> </eClassifiers>
>>>> ...
>>>>
>>>> The issue I'm seeing is that the input and output references of
>>>> InvokeOperation are being mapped quite differently,
>>>> input is a foreign key column in an InvokeOperation table but output
>>>> is not, the OperationOutput table has a foreign key
>>>> back to InvokeOperation but the OperationInput table does not. A guess
>>>> is just one side of the bidirectional
>>>> relationship is represented in the database?
>>>>
>>>> In my application code I create instances of the OperationInput and
>>>> OperationOutput and set them on the InvokeOperation.
>>>> This is fine for the duration of the CDO Server being up but if I
>>>> restart the server and then retrieve my
>>>> InvokeOperation instance then the InvokeOperation#getOutput() returns
>>>> null.
>>>>
>>>> Is there som mapping help I should be providing here to ensure
>>>> consistency or perhaps something peculiar to it being a
>>>> bidirectional reference?
>>>>
>>>>
>>>> Thanks,
>>>> Dan
>>>
>>>
>>
>
--
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
|
|
|
Re: [CDO] Hibernate store mapping issue [message #768538 is a reply to message #768525] |
Tue, 20 December 2011 10:32 |
Dan Pollitt Messages: 55 Registered: August 2010 |
Member |
|
|
Hi Martin,
I tried switching to the DBStore implementation for the repository (with
the same model) and it looks to work ok so that would suggest it isn't
an issue with my .ecore model.
I'll certainly raise a bugzilla - I'll need to replicate the issue in a
different model so that I can share it as an example. Once I've done
that, I'll post back here.
Thanks,
Dan
On 20/12/2011 10:07, Martin Taal wrote:
> Hmm, I checked the mappings/model but I have no idea what happens here,
> can you enter a bugzilla for this (mapping of 2 bidirectional
> containment associations is done differently)? I am not sure if your
> model is very large or if I can use it as an example in the testcases. I
> can try to replicate the issue in a small model, afaics it should be
> doable.
>
> gr. Martin
>
> On 12/20/2011 10:11 AM, Dan Pollitt wrote:
>> I've just checked and it doesn't matter which side of the
>> bidirectional relationship I set in client code, the
>> invokeOperation column in the OperationOutput table remains null.
>>
>> Dan
>>
>> On 20/12/2011 09:03, Dan Pollitt wrote:
>>> Hi Martin,
>>>
>>> Yes I checked in the DB and the invokeOperation column of the
>>> operationoutput table contains a null value.
>>>
>>> I generated the hibernate mapping as you referenced and the sections of
>>> the result relating to InvokeOperation, OperationInput and
>>> OperationOutput are below:
>>>
>>> == generated_hbm.xml ==
>>>
>>> <class entity-name="OperationOutput" abstract="false" lazy="true"
>>> table="`operationoutput`">
>>> <meta attribute="eclassName" inherit="false">OperationOutput</meta>
>>> <meta attribute="epackage"
>>> inherit="false">http://www.example.com/2011/11/tester</meta>
>>> <tuplizer entity-mode="pojo"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <tuplizer entity-mode="dynamic-map"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <id type="long" name="idcol" column="idcol"
>>> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>>>
>>>
>>> <meta attribute="syntheticId" inherit="false">true</meta>
>>> <generator class="native" />
>>> </id>
>>> <property name="resourceID"
>>> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>>>
>>>
>>> <column name="resource_id" />
>>> </property>
>>> <property name="containerID" type="string">
>>> <column name="container_id" />
>>> </property>
>>> <property name="version" type="java.lang.Integer">
>>> <meta attribute="version">true</meta>
>>> <column name="version" />
>>> </property>
>>> <many-to-one name="invokeOperation" entity-name="InvokeOperation"
>>> cascade="merge,persist,save-update,lock" not-null="false" lazy="false"
>>> insert="true" update="true" />
>>> <many-to-one name="assertions" entity-name="HasAssertions"
>>> lazy="false" cascade="all" foreign-key="operationoutput_assertions"
>>> insert="true" update="true" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`hasassertions_assertions_e_id`"
>>> index="OperationOutput_assertions" />
>>> </many-to-one>
>>> <many-to-one name="storeRules" entity-name="HasStoreRules"
>>> lazy="false" cascade="all" foreign-key="operationoutput_storerules"
>>> insert="true" update="true" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`hasstorerules_storerules_e_id`"
>>> index="OperationOutput_storeRules" />
>>> </many-to-one>
>>> </class>
>>> <class entity-name="OperationInput" abstract="false" lazy="true"
>>> table="`operationinput`">
>>> <meta attribute="eclassName" inherit="false">OperationInput</meta>
>>> <meta attribute="epackage"
>>> inherit="false">http://www.example.com/2011/11/tester</meta>
>>> <tuplizer entity-mode="pojo"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <tuplizer entity-mode="dynamic-map"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <id type="long" name="idcol" column="idcol"
>>> access="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOSyntheticIdPropertyHandler">
>>>
>>>
>>> <meta attribute="syntheticId" inherit="false">true</meta>
>>> <generator class="native" />
>>> </id>
>>> <property name="resourceID"
>>> type="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDOIDUserType">
>>>
>>>
>>> <column name="resource_id" />
>>> </property>
>>> <property name="containerID" type="string">
>>> <column name="container_id" />
>>> </property>
>>> <property name="version" type="java.lang.Integer">
>>> <meta attribute="version">true</meta>
>>> <column name="version" />
>>> </property>
>>> <one-to-one name="invokeOperation" entity-name="InvokeOperation"
>>> cascade="merge,persist,save-update,lock" lazy="false"
>>> property-ref="input" />
>>> <many-to-one name="values" entity-name="HasValues" lazy="false"
>>> cascade="all" foreign-key="operationinput_values" insert="true"
>>> update="true" not-null="false">
>>> <column not-null="false" unique="false" name="`hasvalues_values_e_id`"
>>> index="OperationInput_values" />
>>> </many-to-one>
>>> <many-to-one name="storeRules" entity-name="HasStoreRules"
>>> lazy="false" cascade="all" foreign-key="operationinput_storerules"
>>> insert="true" update="true" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`hasstorerules_storerules_e_id`"
>>> index="OperationInput_storeRules" />
>>> </many-to-one>
>>> </class>
>>> <joined-subclass entity-name="InvokeOperation"
>>> abstract="false" lazy="true" extends="Action" table="`invokeoperation`">
>>> <meta attribute="eclassName" inherit="false">InvokeOperation</meta>
>>> <meta attribute="epackage"
>>> inherit="false">http://www.example.com/2011/11/tester</meta>
>>> <tuplizer entity-mode="pojo"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <tuplizer entity-mode="dynamic-map"
>>> class="org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer"
>>>
>>> />
>>> <key>
>>> <column name="`action_e_id`" />
>>> </key>
>>> <many-to-one name="operation" entity-name="Operation"
>>> lazy="false" cascade="merge,persist,save-update,lock"
>>> foreign-key="invokeoperation_operation"
>>> insert="true" update="true" not-null="false">
>>> <column not-null="false" unique="false"
>>> name="`operation_operation_e_id`"
>>> index="InvokeOperation_operation" />
>>> </many-to-one>
>>> <many-to-one name="input" entity-name="OperationInput"
>>> cascade="all" not-null="false" lazy="false" insert="true"
>>> update="true" />
>>> <one-to-one name="output" entity-name="OperationOutput"
>>> cascade="all" lazy="false" property-ref="invokeOperation" />
>>> </joined-subclass>
>>>
>>> =======================
>>>
>>> I'm not sure if that gives us any pointers?
>>>
>>>
>>> Thanks,
>>> Dan
>>>
>>> On 19/12/2011 17:57, Martin Taal wrote:
>>>> Yes just one side of a bi-directional association is represented in the
>>>> database. Teneo uses a specific mechanism to decide on which side of
>>>> the
>>>> bi-directional association the fk should be. It uses alphabetical
>>>> ordering. This is needed because Teneo needs to make the same choice
>>>> consistently. I guess that is the reason that the 2 associations are
>>>> mapped in different directions.
>>>>
>>>> But this does not explain the null value you get when retrieving the
>>>> object. It seems that the database is not filled with the correct
>>>> values, can you check the content of the table and see if the
>>>> OperationOutput column to InvokeOperation has a value?
>>>>
>>>> Can you post the relevant part of the hbm?
>>>> http://wiki.eclipse.org/CDO/Hibernate_Store/Model_Relational_Mapping#Generating_the_mapping.2C_manually_changing_it_and_then_use_the_manual_mapping
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> http://wiki.eclipse.org/CDO/Hibernate_Store/Configuration_and_Setup#How_to_enable_Hibernate_logging
>>>>
>>>>
>>>>
>>>>
>>>> gr. Martin
>>>>
>>>> On 12/19/2011 06:22 PM, Dan Pollitt wrote:
>>>>> Hi all (Martin..),
>>>>>
>>>>> I'm seeing an issue in the OR mapping that has occurred where two
>>>>> references of a class are being handled quite
>>>>> differently.
>>>>>
>>>>> Extract of model I'm using:
>>>>>
>>>>> ...
>>>>> <eClassifiers xsi:type="ecore:EClass" name="InvokeOperation"
>>>>> eSuperTypes="#//Action">
>>>>> ...
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="input"
>>>>> eType="#//OperationInput"
>>>>> containment="true" eOpposite="#//OperationInput/invokeOperation"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="output"
>>>>> eType="#//OperationOutput"
>>>>> containment="true" eOpposite="#//OperationOutput/invokeOperation"/>
>>>>> </eClassifiers>
>>>>>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="OperationOutput">
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="invokeOperation" eType="#//InvokeOperation"
>>>>> eOpposite="#//InvokeOperation/output"/>
>>>>> ...
>>>>> </eClassifiers>
>>>>>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="OperationInput">
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="invokeOperation" eType="#//InvokeOperation"
>>>>> eOpposite="#//InvokeOperation/input"/>
>>>>> ...
>>>>> </eClassifiers>
>>>>> ...
>>>>>
>>>>> The issue I'm seeing is that the input and output references of
>>>>> InvokeOperation are being mapped quite differently,
>>>>> input is a foreign key column in an InvokeOperation table but output
>>>>> is not, the OperationOutput table has a foreign key
>>>>> back to InvokeOperation but the OperationInput table does not. A guess
>>>>> is just one side of the bidirectional
>>>>> relationship is represented in the database?
>>>>>
>>>>> In my application code I create instances of the OperationInput and
>>>>> OperationOutput and set them on the InvokeOperation.
>>>>> This is fine for the duration of the CDO Server being up but if I
>>>>> restart the server and then retrieve my
>>>>> InvokeOperation instance then the InvokeOperation#getOutput() returns
>>>>> null.
>>>>>
>>>>> Is there som mapping help I should be providing here to ensure
>>>>> consistency or perhaps something peculiar to it being a
>>>>> bidirectional reference?
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Dan
>>>>
>>>>
>>>
>>
>
>
|
|
|
Goto Forum:
Current Time: Tue Apr 23 14:42:46 GMT 2024
Powered by FUDForum. Page generated in 0.03681 seconds
|