| [CDO] Querying non persisted EObjects [message #1727923] |
Tue, 29 March 2016 09:01  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03595 seconds