Skip to main content



      Home
Home » Modeling » EMF » [CDO] Querying non persisted EObjects
[CDO] Querying non persisted EObjects [message #1727923] Tue, 29 March 2016 09:01 Go to next message
Eclipse UserFriend
How is it possible to get non persisted EObjects (CDOState NEW) by CDOQuery?

If you add a new EObject to a resource per EMF Command:
Command addCommand = AddCommand.create(EditingDomain, Object, null, Owner);
EditingDomain.getCommandStack().execute(addCommand);


And execute a CDOQuery to get all instances of that type the new object is missing:
CDOQuery query = CDOTransaction().createQuery("ocl", "ObjectClass.allInstances()", owner);
List<EObject> resultList = query.getResult();
Re: [CDO] Querying non persisted EObjects [message #1727941 is a reply to message #1727923] Tue, 29 March 2016 11:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Philipp,

See answers below :

Le 29/03/2016 16:19, Philipp Schweinbenz a écrit :
> How is it possible to get non persisted EObjects (CDOState NEW) by
> CDOQuery?
yes it is possible, and only for the OCL query handler. This is tested
by CDO tests, see OCLQueryTest.
We can look at specifically OCLQueryTest.testNewObject() in CDO base code.

>
> If you add a new EObject to a resource per EMF Command:
> Command addCommand = AddCommand.create(EditingDomain, Object, null, Owner);
> EditingDomain.getCommandStack().execute(addCommand);
>
> And execute a CDOQuery to get all instances of that type the new object
> is missing:
> CDOQuery query = CDOTransaction().createQuery("ocl",
> "ObjectClass.allInstances()", owner);
> List<EObject> resultList = query.getResult();

Best Regards.


--
Esteban Dugueperoux - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [CDO] Querying non persisted EObjects [message #1727985 is a reply to message #1727923] Wed, 30 March 2016 02:14 Go to previous message
Eclipse UserFriend
Hi Esteban,

thanks for your answer, it's working now.

My first problem was, that the query param considerDirtyState was not set to true.

My second problem was, that I used a CompoundCommand including a setCommand first and an addCommand. I triggered the CDOQuery by listening changes on the object which was related by the setCommand and so the new object was not in the resource. As I changed the command order and triggered the addCommand first, everything was working fine.

Best Regards and thanks alot
Philipp Schweinbenz
Previous Topic:Bundle 'org.eclipse.emf.edit.ui' cannot be resolved
Next Topic:Why am I not seeing EMF types in a project with a Plug-in nature?
Goto Forum:
  


Current Time: Wed Nov 05 14:37:49 EST 2025

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

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

Back to the top