Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] References to multiple versions of an object in the same model
[CDO] References to multiple versions of an object in the same model [message #520206] Thu, 11 March 2010 14:51 Go to next message
BastienFriend
Messages: 44
Registered: March 2010
Member
Hi,
I am studying how to use CDORevisions and Audits, in order to reference from objects different versions of a given one.
Here's the way I do it.

I open 2 audits to get the two versions of the object I want to be referenced:
//getting the first version of my object

CDOView audit = session.openAudit(dateV1.getTime());
			
CDOResource resource2 = audit.getResource("myResource");
			
MyContent contentV1 = (MyContent) resource2.getAllContents().next();

//getting the second version of my object

CDOView audit = session.openAudit(dateV2.getTime());
		
CDOResource resource2 = audit.getResource("myResource");
			
MyContent contentV2 = (MyContent) resource2.getAllContents().next();


Here, contentV1 and contentV2 are all right, they contain different informations related to their version.

Then I create the two objects which reference the different versions of the previously defined object:
//getting my CDOResource
Resource resource =  myCDOTransaction.getResource();

//Creating my two eObjects
EObject eObject1= MMFactory.eINSTANCE.createEObject1();					
EObject eObject2= MMFactory.eINSTANCE.createEObject2();

//getting their structural feature
EStructuralFeature eF1 = eObject1.eClass().getEStructuralFeature("MyContent");		
EStructuralFeature eF2= eObject2.eClass().getEStructuralFeature("MyContent");	

//setting the two versions of my object on their structural feature
eObject1.eSet(eF1,contentV1 );
eObject2.eSet(eF2,contentV2 );

//adding the created objects to my CDOResource.
resource.add(eObject1);
resource.add(eObject2);


Until there, everything's fine, eObject1 and eObject2 reference properly the two versions.

But when I commit on the CDO, the two objects I've created actually reference the same version of the object :
//until there, if I get back the structural feature of the two objects, i still get the two different versions
myCDOTransaction.commit();
//but there, they both reference the same version of my object


Is there anything I do wrong? Or is mixing references to multiple versions of an object in the same model not supported in the first place?

Here is my testing environment :
CDO 2.0
Eclipse SDK Version: 3.4.2
Build id: M20090211-1700

Regards,
Bastien


Re: [CDO] References to multiple versions of an object in the same model [message #520230 is a reply to message #520206] Thu, 11 March 2010 16:01 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Hi Bastien,

Comments below...


Am 11.03.2010 15:51, schrieb Bastien:
> Hi,
> I am studying how to use CDORevisions and Audits, in order to
> reference from objects different versions of a given one.
> Here's the way I do it.
>
> I open 2 audits to get the two versions of the object I want to be
> referenced:
>
> //getting the first version of my object
> CDOView audit = session.openAudit(dateV1.getTime());
> CDOResource resource2 = audit.getResource("myResource");
> MyContent contentV1 = (MyContent) resource2.getAllContents().next();
>
>
> //getting the second version of my object
> CDOView audit = session.openAudit(dateV2.getTime());
> CDOResource resource2 = audit.getResource("myResource");
> MyContent contentV2 = (MyContent) resource2.getAllContents().next();
>
>
> Here, contentV1 and contentV2 are all right, they contain different
> informations related to their version.
>
> Then I create the two objects which reference the different versions
> of the previously defined object:
>
> //getting my CDOResource
> Resource resource = myCDOTransaction.getResource();
>
> //Creating my two eObjects
> EObject eObject1= MMFactory.eINSTANCE.createEObject1();
> EObject eObject2= MMFactory.eINSTANCE.createEObject2();
>
> //getting their structural feature
> EStructuralFeature eF1 =
> eObject1.eClass().getEStructuralFeature("MyContent");
> EStructuralFeature eF2=
> eObject2.eClass().getEStructuralFeature("MyContent");
>
> //setting the two versions of my object on their structural feature
> eObject1.eSet(eF1,contentV1 );
> eObject2.eSet(eF2,contentV2 );
No, this is not okay. Note that CDO does not store any version
information with references. The version information is transiently
added by the CDOView. In other words. all objects that you see in a
CDOView are valid at the view's target time stamp.

I'm currently not sure if it's an issue or a feature that the eSet()
call does not complain that you're setting a reference target from
another CDOView. If you open a bugzilla I can eventually investigate that.

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> //adding the created objects to my CDOResource.
> resource.add(eObject1);
> resource.add(eObject2);
>
>
> Until there, everything's fine, eObject1 and eObject2 reference
> properly the two versions.
>
> But when I commit on the CDO, the two objects I've created actually
> reference the same version of the object :
>
> //until there, if I get back the structural feature of the two
> objects, i still get the two different versions
> myCDOTransaction.commit();
> //but there, they both reference the same version of my object
>
>
> Is there anything I do wrong? Or is mixing references to multiple
> versions of an object in the same model not supported in the first place?
>
> Here is my testing environment : CDO 2.0
> Eclipse SDK Version: 3.4.2
> Build id: M20090211-1700
>
> Regards,
> Bastien
>
>
>


Re: [CDO] References to multiple versions of an object in the same model [message #520237 is a reply to message #520206] Thu, 11 March 2010 16:33 Go to previous message
BastienFriend
Messages: 44
Registered: March 2010
Member
Thanks Eike for your explanation.
Here's the bugzilla:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=305527

Regards,
Bastien.
Previous Topic:[CDO] Error at first commit to an CDO server instance
Next Topic:[Teneo] Handling of Hibernate/Oracle Blobs
Goto Forum:
  


Current Time: Tue Sep 24 15:12:46 GMT 2024

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

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

Back to the top