Skip to main content



      Home
Home » Modeling » EMF » [Teneo] sdo serialization and equality with idbag or index
[Teneo] sdo serialization and equality with idbag or index [message #498560] Tue, 17 November 2009 08:58 Go to next message
Eclipse UserFriend
Hi all,

I have had problem of deadlock with a simple n:m relation.
I have understood that it was probably because of that I declare no
index or idbag on my relation, and so on each change hibernate remove
several entries to reinsert those not really removed.

So I am trying to use idbag or index and I have problem of equality of
this object after a serialization-deserialization (it worked well before)
We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
The method to test the equality is EcoreUtil.equals

Is this kind of problem is telling you something ?
What can I do to find a solution to my problem.

Thanks for your help.
Regards

Thomas
Re: [Teneo] sdo serialization and equality with idbag or index [message #498561 is a reply to message #498560] Tue, 17 November 2009 09:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi Thomas,
I am afraid that it does not directly ring a bell with me. Can you create a small testmodel which reproduces the issues?

Also on what check does the equality fail (in EcoreUtil.EqualityHelper?

gr. Martin

Thomas Franconville wrote:
> Hi all,
>
> I have had problem of deadlock with a simple n:m relation.
> I have understood that it was probably because of that I declare no
> index or idbag on my relation, and so on each change hibernate remove
> several entries to reinsert those not really removed.
>
> So I am trying to use idbag or index and I have problem of equality of
> this object after a serialization-deserialization (it worked well before)
> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
> The method to test the equality is EcoreUtil.equals
>
> Is this kind of problem is telling you something ?
> What can I do to find a solution to my problem.
>
> Thanks for your help.
> Regards
>
> Thomas


--

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: [Teneo] sdo serialization and equality with idbag or index [message #498592 is a reply to message #498561] Tue, 17 November 2009 10:36 Go to previous messageGo to next message
Eclipse UserFriend
It is on the method
public boolean equals(EObject eObject1, EObject eObject2)

on these return:
// Both eObject1 and eObject2 are not null.
// If eObject1 has been compared already...
//
Object eObject1MappedValue = get(eObject1);
if (eObject1MappedValue != null)
{
// Then eObject2 must be that previous match.
//
return eObject1MappedValue == eObject2;
}

Here is the thread stack

Thread [Main Thread] (Suspended)
EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
EReference) line: 2246
EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
EStructuralFeature) line: 2226
EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line: 2202
EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
EReference) line: 2245
EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
EStructuralFeature) line: 2226
EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
EcoreUtil.equals(EObject, EObject) line: 2047
BasicSerializationTest.testSerializeResource() line: 88
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
TestMethod.invoke(Object) line: 59
MethodRoadie.runTestMethod() line: 98
MethodRoadie$2.run() line: 79
MethodRoadie.runBeforesThenTestThenAfters(Runnable) line: 87
MethodRoadie.runTest() line: 77
MethodRoadie.run() line: 42
JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line: 88
JUnit4ClassRunner.runMethods(RunNotifier) line: 51
JUnit4ClassRunner$1.run() line: 44
ClassRoadie.runUnprotected() line: 27
ClassRoadie.runProtected() line: 37
JUnit4ClassRunner.run(RunNotifier) line: 42
JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion) line: 46
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
RemoteTestRunner.runTests(TestExecution) line: 683
RemoteTestRunner.run() line: 390
RemoteTestRunner.main(String[]) line: 197


Martin Taal a écrit :
> Hi Thomas,
> I am afraid that it does not directly ring a bell with me. Can you
> create a small testmodel which reproduces the issues?
>
> Also on what check does the equality fail (in EcoreUtil.EqualityHelper?
>
> gr. Martin
>
> Thomas Franconville wrote:
>> Hi all,
>>
>> I have had problem of deadlock with a simple n:m relation.
>> I have understood that it was probably because of that I declare no
>> index or idbag on my relation, and so on each change hibernate remove
>> several entries to reinsert those not really removed.
>>
>> So I am trying to use idbag or index and I have problem of equality of
>> this object after a serialization-deserialization (it worked well before)
>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>> The method to test the equality is EcoreUtil.equals
>>
>> Is this kind of problem is telling you something ?
>> What can I do to find a solution to my problem.
>>
>> Thanks for your help.
>> Regards
>>
>> Thomas
>
>
Re: [Teneo] sdo serialization and equality with idbag or index [message #498594 is a reply to message #498592] Tue, 17 November 2009 10:46 Go to previous messageGo to next message
Eclipse UserFriend
I have found where it is coming from.
I have overridden methods equals and hashcode for another problem

/**
* @generated NOT
*/
@Override
public int hashCode()
{
if(id == null)
{
return super.hashCode();
}
else
{
return id.hashCode();
}
}

/**
* @generated NOT
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (!(obj instanceof SubActivityImpl))
{
return false;
}
SubActivityImpl other = (SubActivityImpl) obj;
if (id == null)
{
if (other.id != null)
{
return false;
}
else
{
return super.equals(obj);
}
}
else if (!id.equals(other.id))
{
return false;
}
return true;
}

Id is a String which is our key.

Without those method, I have this Exception:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:546)
at java.util.ArrayList.get(ArrayList.java:321)
at org.hibernate.collection.PersistentBag.get(PersistentBag.jav a:423)
at
org.eclipse.emf.common.util.DelegatingEList.delegateGet(Dele gatingEList.java:407)
at
org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eGet(PersistableEList.java:399)
at
org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:396)
at
com.oslo.dreams.model.impl.SaveAssignedTest.testSaveAssigned ResourcesOnSubActivitiesWithData(SaveAssignedTest.java:486)



Thomas Franconville a écrit :
> It is on the method
> public boolean equals(EObject eObject1, EObject eObject2)
>
> on these return:
> // Both eObject1 and eObject2 are not null.
> // If eObject1 has been compared already...
> //
> Object eObject1MappedValue = get(eObject1);
> if (eObject1MappedValue != null)
> {
> // Then eObject2 must be that previous match.
> //
> return eObject1MappedValue == eObject2;
> }
>
> Here is the thread stack
>
> Thread [Main Thread] (Suspended)
> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
> EReference) line: 2246
> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
> EStructuralFeature) line: 2226
> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
> EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line:
> 2202
> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
> EReference) line: 2245
> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
> EStructuralFeature) line: 2226
> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
> EcoreUtil.equals(EObject, EObject) line: 2047
> BasicSerializationTest.testSerializeResource() line: 88
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
> available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> TestMethod.invoke(Object) line: 59
> MethodRoadie.runTestMethod() line: 98
> MethodRoadie$2.run() line: 79
> MethodRoadie.runBeforesThenTestThenAfters(Runnable) line: 87
> MethodRoadie.runTest() line: 77
> MethodRoadie.run() line: 42
> JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line: 88
> JUnit4ClassRunner.runMethods(RunNotifier) line: 51
> JUnit4ClassRunner$1.run() line: 44
> ClassRoadie.runUnprotected() line: 27
> ClassRoadie.runProtected() line: 37
> JUnit4ClassRunner.run(RunNotifier) line: 42
> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion)
> line: 46
> TestExecution.run(ITestReference[]) line: 38
> RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
> RemoteTestRunner.runTests(TestExecution) line: 683
> RemoteTestRunner.run() line: 390
> RemoteTestRunner.main(String[]) line: 197
>
>
> Martin Taal a écrit :
>> Hi Thomas,
>> I am afraid that it does not directly ring a bell with me. Can you
>> create a small testmodel which reproduces the issues?
>>
>> Also on what check does the equality fail (in EcoreUtil.EqualityHelper?
>>
>> gr. Martin
>>
>> Thomas Franconville wrote:
>>> Hi all,
>>>
>>> I have had problem of deadlock with a simple n:m relation.
>>> I have understood that it was probably because of that I declare no
>>> index or idbag on my relation, and so on each change hibernate remove
>>> several entries to reinsert those not really removed.
>>>
>>> So I am trying to use idbag or index and I have problem of equality
>>> of this object after a serialization-deserialization (it worked well
>>> before)
>>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>>> The method to test the equality is EcoreUtil.equals
>>>
>>> Is this kind of problem is telling you something ?
>>> What can I do to find a solution to my problem.
>>>
>>> Thanks for your help.
>>> Regards
>>>
>>> Thomas
>>
>>
Re: [Teneo] sdo serialization and equality with idbag or index [message #498602 is a reply to message #498594] Tue, 17 November 2009 11:16 Go to previous messageGo to next message
Eclipse UserFriend
It's ok. I have found the problem and a work around.

So, what I am doing in this test, is to create an object and the
association (where I need the idbag or index)
I am doing then a query on these object, and the object returned has an
empty list. if I do a refresh on it, the list is filled.

It is quite stange as it works if there is no idbag or index and data
are in the object use to create/store in database, and are well stored.

Thomas Franconville a écrit :
> I have found where it is coming from.
> I have overridden methods equals and hashcode for another problem
>
> /**
> * @generated NOT
> */
> @Override
> public int hashCode()
> {
> if(id == null)
> {
> return super.hashCode();
> }
> else
> {
> return id.hashCode();
> }
> }
>
> /**
> * @generated NOT
> */
> @Override
> public boolean equals(Object obj)
> {
> if (this == obj)
> {
> return true;
> }
> if (obj == null)
> {
> return false;
> }
> if (!(obj instanceof SubActivityImpl))
> {
> return false;
> }
> SubActivityImpl other = (SubActivityImpl) obj;
> if (id == null)
> {
> if (other.id != null)
> {
> return false;
> }
> else
> {
> return super.equals(obj);
> }
> }
> else if (!id.equals(other.id))
> {
> return false;
> }
> return true;
> }
>
> Id is a String which is our key.
>
> Without those method, I have this Exception:
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> at java.util.ArrayList.RangeCheck(ArrayList.java:546)
> at java.util.ArrayList.get(ArrayList.java:321)
> at org.hibernate.collection.PersistentBag.get(PersistentBag.jav a:423)
> at
> org.eclipse.emf.common.util.DelegatingEList.delegateGet(Dele gatingEList.java:407)
>
> at
> org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eGet(PersistableEList.java:399)
>
> at
> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:396)
> at
> com.oslo.dreams.model.impl.SaveAssignedTest.testSaveAssigned ResourcesOnSubActivitiesWithData(SaveAssignedTest.java:486)
>
>
>
>
> Thomas Franconville a écrit :
>> It is on the method
>> public boolean equals(EObject eObject1, EObject eObject2)
>>
>> on these return:
>> // Both eObject1 and eObject2 are not null.
>> // If eObject1 has been compared already...
>> //
>> Object eObject1MappedValue = get(eObject1);
>> if (eObject1MappedValue != null)
>> {
>> // Then eObject2 must be that previous match.
>> //
>> return eObject1MappedValue == eObject2;
>> }
>>
>> Here is the thread stack
>>
>> Thread [Main Thread] (Suspended)
>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
>> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
>> EReference) line: 2246
>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>> EStructuralFeature) line: 2226
>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>> EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line:
>> 2202 EcoreUtil$EqualityHelper.haveEqualReference(EObject,
>> EObject, EReference) line: 2245
>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>> EStructuralFeature) line: 2226
>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>> EcoreUtil.equals(EObject, EObject) line: 2047
>> BasicSerializationTest.testSerializeResource() line: 88
>> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
>> available [native method]
>> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
>> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
>> Method.invoke(Object, Object...) line: 585
>> TestMethod.invoke(Object) line: 59 MethodRoadie.runTestMethod()
>> line: 98 MethodRoadie$2.run() line: 79
>> MethodRoadie.runBeforesThenTestThenAfters(Runnable) line: 87
>> MethodRoadie.runTest() line: 77 MethodRoadie.run() line: 42
>> JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line: 88
>> JUnit4ClassRunner.runMethods(RunNotifier) line: 51
>> JUnit4ClassRunner$1.run() line: 44 ClassRoadie.runUnprotected()
>> line: 27 ClassRoadie.runProtected() line: 37
>> JUnit4ClassRunner.run(RunNotifier) line: 42
>> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion)
>> line: 46 TestExecution.run(ITestReference[]) line: 38
>> RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
>> RemoteTestRunner.runTests(TestExecution) line: 683
>> RemoteTestRunner.run() line: 390 RemoteTestRunner.main(String[])
>> line: 197
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> I am afraid that it does not directly ring a bell with me. Can you
>>> create a small testmodel which reproduces the issues?
>>>
>>> Also on what check does the equality fail (in EcoreUtil.EqualityHelper?
>>>
>>> gr. Martin
>>>
>>> Thomas Franconville wrote:
>>>> Hi all,
>>>>
>>>> I have had problem of deadlock with a simple n:m relation.
>>>> I have understood that it was probably because of that I declare no
>>>> index or idbag on my relation, and so on each change hibernate
>>>> remove several entries to reinsert those not really removed.
>>>>
>>>> So I am trying to use idbag or index and I have problem of equality
>>>> of this object after a serialization-deserialization (it worked well
>>>> before)
>>>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>>>> The method to test the equality is EcoreUtil.equals
>>>>
>>>> Is this kind of problem is telling you something ?
>>>> What can I do to find a solution to my problem.
>>>>
>>>> Thanks for your help.
>>>> Regards
>>>>
>>>> Thomas
>>>
>>>
Re: [Teneo] sdo serialization and equality with idbag or index [message #498621 is a reply to message #498602] Tue, 17 November 2009 12:14 Go to previous messageGo to next message
Eclipse UserFriend
Hi Thomas,
It still sounds a bit strange... It is possible that the EqualHelper tests something on the list which does not force
the list to be loaded (while it should), could that be the case?

What do you mean with refresh the object/list?

gr. Martin

Thomas Franconville wrote:
> It's ok. I have found the problem and a work around.
>
> So, what I am doing in this test, is to create an object and the
> association (where I need the idbag or index)
> I am doing then a query on these object, and the object returned has an
> empty list. if I do a refresh on it, the list is filled.
>
> It is quite stange as it works if there is no idbag or index and data
> are in the object use to create/store in database, and are well stored.
>
> Thomas Franconville a écrit :
>> I have found where it is coming from.
>> I have overridden methods equals and hashcode for another problem
>>
>> /**
>> * @generated NOT
>> */
>> @Override
>> public int hashCode()
>> {
>> if(id == null)
>> {
>> return super.hashCode();
>> }
>> else
>> {
>> return id.hashCode(); }
>> }
>>
>> /**
>> * @generated NOT
>> */
>> @Override
>> public boolean equals(Object obj)
>> {
>> if (this == obj)
>> {
>> return true;
>> }
>> if (obj == null)
>> {
>> return false;
>> }
>> if (!(obj instanceof SubActivityImpl))
>> {
>> return false;
>> }
>> SubActivityImpl other = (SubActivityImpl) obj;
>> if (id == null)
>> {
>> if (other.id != null)
>> {
>> return false;
>> }
>> else
>> {
>> return super.equals(obj);
>> }
>> }
>> else if (!id.equals(other.id))
>> {
>> return false;
>> }
>> return true;
>> }
>>
>> Id is a String which is our key.
>>
>> Without those method, I have this Exception:
>> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
>> at java.util.ArrayList.RangeCheck(ArrayList.java:546)
>> at java.util.ArrayList.get(ArrayList.java:321)
>> at org.hibernate.collection.PersistentBag.get(PersistentBag.jav a:423)
>> at
>> org.eclipse.emf.common.util.DelegatingEList.delegateGet(Dele gatingEList.java:407)
>>
>> at
>> org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eGet(PersistableEList.java:399)
>>
>> at
>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:396)
>> at
>> com.oslo.dreams.model.impl.SaveAssignedTest.testSaveAssigned ResourcesOnSubActivitiesWithData(SaveAssignedTest.java:486)
>>
>>
>>
>>
>> Thomas Franconville a écrit :
>>> It is on the method
>>> public boolean equals(EObject eObject1, EObject eObject2)
>>>
>>> on these return:
>>> // Both eObject1 and eObject2 are not null.
>>> // If eObject1 has been compared already...
>>> //
>>> Object eObject1MappedValue = get(eObject1);
>>> if (eObject1MappedValue != null)
>>> {
>>> // Then eObject2 must be that previous match.
>>> //
>>> return eObject1MappedValue == eObject2;
>>> }
>>>
>>> Here is the thread stack
>>>
>>> Thread [Main Thread] (Suspended)
>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
>>> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
>>> EReference) line: 2246
>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>> EStructuralFeature) line: 2226
>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>> EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line:
>>> 2202 EcoreUtil$EqualityHelper.haveEqualReference(EObject,
>>> EObject, EReference) line: 2245
>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>> EStructuralFeature) line: 2226
>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>> EcoreUtil.equals(EObject, EObject) line: 2047
>>> BasicSerializationTest.testSerializeResource() line: 88
>>> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
>>> available [native method]
>>> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
>>> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
>>> Method.invoke(Object, Object...) line: 585
>>> TestMethod.invoke(Object) line: 59 MethodRoadie.runTestMethod()
>>> line: 98 MethodRoadie$2.run() line: 79
>>> MethodRoadie.runBeforesThenTestThenAfters(Runnable) line: 87
>>> MethodRoadie.runTest() line: 77 MethodRoadie.run() line: 42
>>> JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line:
>>> 88 JUnit4ClassRunner.runMethods(RunNotifier) line: 51
>>> JUnit4ClassRunner$1.run() line: 44 ClassRoadie.runUnprotected()
>>> line: 27 ClassRoadie.runProtected() line: 37
>>> JUnit4ClassRunner.run(RunNotifier) line: 42
>>> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion)
>>> line: 46 TestExecution.run(ITestReference[]) line: 38
>>> RemoteTestRunner.runTests(String[], String, TestExecution) line:
>>> 467 RemoteTestRunner.runTests(TestExecution) line: 683
>>> RemoteTestRunner.run() line: 390
>>> RemoteTestRunner.main(String[]) line: 197
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> I am afraid that it does not directly ring a bell with me. Can you
>>>> create a small testmodel which reproduces the issues?
>>>>
>>>> Also on what check does the equality fail (in EcoreUtil.EqualityHelper?
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas Franconville wrote:
>>>>> Hi all,
>>>>>
>>>>> I have had problem of deadlock with a simple n:m relation.
>>>>> I have understood that it was probably because of that I declare no
>>>>> index or idbag on my relation, and so on each change hibernate
>>>>> remove several entries to reinsert those not really removed.
>>>>>
>>>>> So I am trying to use idbag or index and I have problem of equality
>>>>> of this object after a serialization-deserialization (it worked
>>>>> well before)
>>>>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>>>>> The method to test the equality is EcoreUtil.equals
>>>>>
>>>>> Is this kind of problem is telling you something ?
>>>>> What can I do to find a solution to my problem.
>>>>>
>>>>> Thanks for your help.
>>>>> Regards
>>>>>
>>>>> Thomas
>>>>
>>>>


--

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: [Teneo] sdo serialization and equality with idbag or index [message #498718 is a reply to message #498621] Wed, 18 November 2009 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Martin,

What is strange is that ever in a debug mode, when I read the list, the
debugger doesn't try to lazy load the relation and the list is well a
HibernatePersistentEList

I mean by refresh the object, I do a entityManager.refresh(myObject)
where myObject is the containing object.



Martin Taal a écrit :
> Hi Thomas,
> It still sounds a bit strange... It is possible that the EqualHelper
> tests something on the list which does not force the list to be loaded
> (while it should), could that be the case?
>
> What do you mean with refresh the object/list?
>
> gr. Martin
>
> Thomas Franconville wrote:
>> It's ok. I have found the problem and a work around.
>>
>> So, what I am doing in this test, is to create an object and the
>> association (where I need the idbag or index)
>> I am doing then a query on these object, and the object returned has
>> an empty list. if I do a refresh on it, the list is filled.
>>
>> It is quite stange as it works if there is no idbag or index and data
>> are in the object use to create/store in database, and are well stored.
>>
>> Thomas Franconville a écrit :
>>> I have found where it is coming from.
>>> I have overridden methods equals and hashcode for another problem
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> @Override
>>> public int hashCode()
>>> {
>>> if(id == null)
>>> {
>>> return super.hashCode();
>>> }
>>> else
>>> {
>>> return id.hashCode(); }
>>> }
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> @Override
>>> public boolean equals(Object obj)
>>> {
>>> if (this == obj)
>>> {
>>> return true;
>>> }
>>> if (obj == null)
>>> {
>>> return false;
>>> }
>>> if (!(obj instanceof SubActivityImpl))
>>> {
>>> return false;
>>> }
>>> SubActivityImpl other = (SubActivityImpl) obj;
>>> if (id == null)
>>> {
>>> if (other.id != null)
>>> {
>>> return false;
>>> }
>>> else
>>> {
>>> return super.equals(obj);
>>> }
>>> }
>>> else if (!id.equals(other.id))
>>> {
>>> return false;
>>> }
>>> return true;
>>> }
>>>
>>> Id is a String which is our key.
>>>
>>> Without those method, I have this Exception:
>>> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
>>> at java.util.ArrayList.RangeCheck(ArrayList.java:546)
>>> at java.util.ArrayList.get(ArrayList.java:321)
>>> at
>>> org.hibernate.collection.PersistentBag.get(PersistentBag.jav a:423)
>>> at
>>> org.eclipse.emf.common.util.DelegatingEList.delegateGet(Dele gatingEList.java:407)
>>>
>>> at
>>> org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eGet(PersistableEList.java:399)
>>>
>>> at
>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:396)
>>>
>>> at
>>> com.oslo.dreams.model.impl.SaveAssignedTest.testSaveAssigned ResourcesOnSubActivitiesWithData(SaveAssignedTest.java:486)
>>>
>>>
>>>
>>>
>>> Thomas Franconville a écrit :
>>>> It is on the method
>>>> public boolean equals(EObject eObject1, EObject eObject2)
>>>>
>>>> on these return:
>>>> // Both eObject1 and eObject2 are not null.
>>>> // If eObject1 has been compared already...
>>>> //
>>>> Object eObject1MappedValue = get(eObject1);
>>>> if (eObject1MappedValue != null)
>>>> {
>>>> // Then eObject2 must be that previous match.
>>>> //
>>>> return eObject1MappedValue == eObject2;
>>>> }
>>>>
>>>> Here is the thread stack
>>>>
>>>> Thread [Main Thread] (Suspended)
>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
>>>> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
>>>> EReference) line: 2246
>>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>>> EStructuralFeature) line: 2226
>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>>> EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line:
>>>> 2202 EcoreUtil$EqualityHelper.haveEqualReference(EObject,
>>>> EObject, EReference) line: 2245
>>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>>> EStructuralFeature) line: 2226
>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>>> EcoreUtil.equals(EObject, EObject) line: 2047
>>>> BasicSerializationTest.testSerializeResource() line: 88
>>>> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
>>>> available [native method]
>>>> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
>>>> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
>>>> Method.invoke(Object, Object...) line: 585
>>>> TestMethod.invoke(Object) line: 59
>>>> MethodRoadie.runTestMethod() line: 98 MethodRoadie$2.run()
>>>> line: 79 MethodRoadie.runBeforesThenTestThenAfters(Runnable)
>>>> line: 87 MethodRoadie.runTest() line: 77
>>>> MethodRoadie.run() line: 42
>>>> JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line:
>>>> 88 JUnit4ClassRunner.runMethods(RunNotifier) line: 51
>>>> JUnit4ClassRunner$1.run() line: 44
>>>> ClassRoadie.runUnprotected() line: 27
>>>> ClassRoadie.runProtected() line: 37
>>>> JUnit4ClassRunner.run(RunNotifier) line: 42
>>>> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion)
>>>> line: 46 TestExecution.run(ITestReference[]) line: 38
>>>> RemoteTestRunner.runTests(String[], String, TestExecution) line:
>>>> 467 RemoteTestRunner.runTests(TestExecution) line: 683
>>>> RemoteTestRunner.run() line: 390
>>>> RemoteTestRunner.main(String[]) line: 197 Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> I am afraid that it does not directly ring a bell with me. Can you
>>>>> create a small testmodel which reproduces the issues?
>>>>>
>>>>> Also on what check does the equality fail (in
>>>>> EcoreUtil.EqualityHelper?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas Franconville wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I have had problem of deadlock with a simple n:m relation.
>>>>>> I have understood that it was probably because of that I declare
>>>>>> no index or idbag on my relation, and so on each change hibernate
>>>>>> remove several entries to reinsert those not really removed.
>>>>>>
>>>>>> So I am trying to use idbag or index and I have problem of
>>>>>> equality of this object after a serialization-deserialization (it
>>>>>> worked well before)
>>>>>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>>>>>> The method to test the equality is EcoreUtil.equals
>>>>>>
>>>>>> Is this kind of problem is telling you something ?
>>>>>> What can I do to find a solution to my problem.
>>>>>>
>>>>>> Thanks for your help.
>>>>>> Regards
>>>>>>
>>>>>> Thomas
>>>>>
>>>>>
>
>
Re: [Teneo] sdo serialization and equality with idbag or index [message #498720 is a reply to message #498718] Wed, 18 November 2009 06:23 Go to previous message
Eclipse UserFriend
Hi Thomas,
Yes indeed strange, it would be great if you can create a small test model/case which replicates the behavior...

gr. Martin

Thomas Franconville wrote:
> Hi Martin,
>
> What is strange is that ever in a debug mode, when I read the list, the
> debugger doesn't try to lazy load the relation and the list is well a
> HibernatePersistentEList
>
> I mean by refresh the object, I do a entityManager.refresh(myObject)
> where myObject is the containing object.
>
>
>
> Martin Taal a écrit :
>> Hi Thomas,
>> It still sounds a bit strange... It is possible that the EqualHelper
>> tests something on the list which does not force the list to be loaded
>> (while it should), could that be the case?
>>
>> What do you mean with refresh the object/list?
>>
>> gr. Martin
>>
>> Thomas Franconville wrote:
>>> It's ok. I have found the problem and a work around.
>>>
>>> So, what I am doing in this test, is to create an object and the
>>> association (where I need the idbag or index)
>>> I am doing then a query on these object, and the object returned has
>>> an empty list. if I do a refresh on it, the list is filled.
>>>
>>> It is quite stange as it works if there is no idbag or index and data
>>> are in the object use to create/store in database, and are well stored.
>>>
>>> Thomas Franconville a écrit :
>>>> I have found where it is coming from.
>>>> I have overridden methods equals and hashcode for another problem
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> @Override
>>>> public int hashCode()
>>>> {
>>>> if(id == null)
>>>> {
>>>> return super.hashCode();
>>>> }
>>>> else
>>>> {
>>>> return id.hashCode(); }
>>>> }
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> @Override
>>>> public boolean equals(Object obj)
>>>> {
>>>> if (this == obj)
>>>> {
>>>> return true;
>>>> }
>>>> if (obj == null)
>>>> {
>>>> return false;
>>>> }
>>>> if (!(obj instanceof SubActivityImpl))
>>>> {
>>>> return false;
>>>> }
>>>> SubActivityImpl other = (SubActivityImpl) obj;
>>>> if (id == null)
>>>> {
>>>> if (other.id != null)
>>>> {
>>>> return false;
>>>> }
>>>> else
>>>> {
>>>> return super.equals(obj);
>>>> }
>>>> }
>>>> else if (!id.equals(other.id))
>>>> {
>>>> return false;
>>>> }
>>>> return true;
>>>> }
>>>>
>>>> Id is a String which is our key.
>>>>
>>>> Without those method, I have this Exception:
>>>> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
>>>> at java.util.ArrayList.RangeCheck(ArrayList.java:546)
>>>> at java.util.ArrayList.get(ArrayList.java:321)
>>>> at
>>>> org.hibernate.collection.PersistentBag.get(PersistentBag.jav a:423)
>>>> at
>>>> org.eclipse.emf.common.util.DelegatingEList.delegateGet(Dele gatingEList.java:407)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.mapping.elist.PersistableEList.delegat eGet(PersistableEList.java:399)
>>>>
>>>> at
>>>> org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEL ist.java:396)
>>>>
>>>> at
>>>> com.oslo.dreams.model.impl.SaveAssignedTest.testSaveAssigned ResourcesOnSubActivitiesWithData(SaveAssignedTest.java:486)
>>>>
>>>>
>>>>
>>>>
>>>> Thomas Franconville a écrit :
>>>>> It is on the method
>>>>> public boolean equals(EObject eObject1, EObject eObject2)
>>>>>
>>>>> on these return:
>>>>> // Both eObject1 and eObject2 are not null.
>>>>> // If eObject1 has been compared already...
>>>>> //
>>>>> Object eObject1MappedValue = get(eObject1);
>>>>> if (eObject1MappedValue != null)
>>>>> {
>>>>> // Then eObject2 must be that previous match.
>>>>> //
>>>>> return eObject1MappedValue == eObject2;
>>>>> }
>>>>>
>>>>> Here is the thread stack
>>>>>
>>>>> Thread [Main Thread] (Suspended)
>>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2122
>>>>> EcoreUtil$EqualityHelper.haveEqualReference(EObject, EObject,
>>>>> EReference) line: 2246
>>>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>>>> EStructuralFeature) line: 2226
>>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>>>> EcoreUtil$EqualityHelper.equals(List<EObject>, List<EObject>) line:
>>>>> 2202 EcoreUtil$EqualityHelper.haveEqualReference(EObject,
>>>>> EObject, EReference) line: 2245
>>>>> EcoreUtil$EqualityHelper.haveEqualFeature(EObject, EObject,
>>>>> EStructuralFeature) line: 2226
>>>>> EcoreUtil$EqualityHelper.equals(EObject, EObject) line: 2171
>>>>> EcoreUtil.equals(EObject, EObject) line: 2047
>>>>> BasicSerializationTest.testSerializeResource() line: 88
>>>>> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
>>>>> not available [native method]
>>>>> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
>>>>> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line:
>>>>> 25 Method.invoke(Object, Object...) line: 585
>>>>> TestMethod.invoke(Object) line: 59
>>>>> MethodRoadie.runTestMethod() line: 98 MethodRoadie$2.run()
>>>>> line: 79 MethodRoadie.runBeforesThenTestThenAfters(Runnable)
>>>>> line: 87 MethodRoadie.runTest() line: 77
>>>>> MethodRoadie.run() line: 42
>>>>> JUnit4ClassRunner.invokeTestMethod(Method, RunNotifier) line:
>>>>> 88 JUnit4ClassRunner.runMethods(RunNotifier) line: 51
>>>>> JUnit4ClassRunner$1.run() line: 44
>>>>> ClassRoadie.runUnprotected() line: 27
>>>>> ClassRoadie.runProtected() line: 37
>>>>> JUnit4ClassRunner.run(RunNotifier) line: 42
>>>>> JUnit4TestMethodReference(JUnit4TestReference).run(TestExecu tion)
>>>>> line: 46 TestExecution.run(ITestReference[]) line: 38
>>>>> RemoteTestRunner.runTests(String[], String, TestExecution) line:
>>>>> 467 RemoteTestRunner.runTests(TestExecution) line: 683
>>>>> RemoteTestRunner.run() line: 390
>>>>> RemoteTestRunner.main(String[]) line: 197 Martin Taal a écrit :
>>>>>> Hi Thomas,
>>>>>> I am afraid that it does not directly ring a bell with me. Can you
>>>>>> create a small testmodel which reproduces the issues?
>>>>>>
>>>>>> Also on what check does the equality fail (in
>>>>>> EcoreUtil.EqualityHelper?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Thomas Franconville wrote:
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I have had problem of deadlock with a simple n:m relation.
>>>>>>> I have understood that it was probably because of that I declare
>>>>>>> no index or idbag on my relation, and so on each change hibernate
>>>>>>> remove several entries to reinsert those not really removed.
>>>>>>>
>>>>>>> So I am trying to use idbag or index and I have problem of
>>>>>>> equality of this object after a serialization-deserialization (it
>>>>>>> worked well before)
>>>>>>> We are using Teneo 1.1.0 / EMF 2.4.3 and sdo serialization.
>>>>>>> The method to test the equality is EcoreUtil.equals
>>>>>>>
>>>>>>> Is this kind of problem is telling you something ?
>>>>>>> What can I do to find a solution to my problem.
>>>>>>>
>>>>>>> Thanks for your help.
>>>>>>> Regards
>>>>>>>
>>>>>>> Thomas
>>>>>>
>>>>>>
>>
>>


--

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
Previous Topic:Resources that are removed from the ResourceSet reappear
Next Topic:EPackageRegistry in multi-threaded environment
Goto Forum:
  


Current Time: Sat Nov 08 04:33:27 EST 2025

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

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

Back to the top