Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » CDO OCLQuery([EMF-Entity]->allInstances()->size() not supported)
CDO OCLQuery [message #1229814] Fri, 10 January 2014 09:28 Go to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Hi,

i tried to run OCLQueries "[EMF-Entity].allInstances()-size()" with CDO. I get as result: not supported. I checked the sources http://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.server.ocl/src/org/eclipse/emf/cdo/server/ocl/OCLExtentCreator.java. Is that the right class? There is just a thrown exception. The example page shows a size() example (http://wiki.eclipse.org/CDOQuery_OCL).

Am i right here? What else do i have to do?

Thanks
Philippe

[Updated on: Fri, 10 January 2014 09:29]

Report message to a moderator

Re: CDO OCLQuery [message #1229820 is a reply to message #1229814] Fri, 10 January 2014 09:42 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Phil,

Please ask CDO questions on the EMF forum.

Comments below...


Am 10.01.2014 10:28, schrieb Phil Wim:
> Hi,
>
> i tried to run OCLQueries "[EMF-Entity].allInstances()-size()"
Should that be "[EMF-Entity].allInstances()->size()"? Note the "->" instead of "-".


> with CDO. I get as result: not supported. I checked the sources
> http://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.server.ocl/src/org/eclipse/emf/cdo/server/ocl/OCLExtentCreator.java.
> Is that the right class? There is just a thrown exception. The exmaple page show a size() example
> (http://wiki.eclipse.org/CDOQuery_OCL).
Yeah, that example says "->size()" ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> Am i right here? What else do i have to do?
>
> Thanks Philippe


Re: CDO OCLQuery [message #1229829 is a reply to message #1229820] Fri, 10 January 2014 10:07 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
I thought it's kind of an EMFT. Sorry! Next question i will start in EMF Forum. Smile

My source code was right, though. I simply forgot the missing ">".

This is my code:

CDOQuery cqo = transaction.createQuery("ocl","Composite.allInstances()->size()");           
int result = cqo.getResultValue();


I receive following exception:

Exception in thread "main" org.eclipse.net4j.signal.RemoteException: java.lang.Error: Not supported
	at org.eclipse.net4j.signal.RequestWithConfirmation.getRemoteException(RequestWithConfirmation.java:141)
	at org.eclipse.net4j.signal.RequestWithConfirmation.setRemoteException(RequestWithConfirmation.java:130)
	at org.eclipse.net4j.signal.SignalProtocol.handleRemoteException(SignalProtocol.java:465)
	at org.eclipse.net4j.signal.RemoteExceptionIndication.indicating(RemoteExceptionIndication.java:66)
	at org.eclipse.net4j.signal.Indication.doExtendedInput(Indication.java:57)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
	at org.eclipse.net4j.signal.Indication.execute(Indication.java:51)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:253)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:149)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.Error: Not supported
	at org.eclipse.emf.cdo.server.ocl.CDOExtentCreator$Lazy$1.size(CDOExtentCreator.java:392)
	at org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:547)
	at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:390)
	at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
	at org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(QueryImpl.java:152)
	at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.evaluate(OCLQueryHandler.java:233)
	at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.executeQuery(OCLQueryHandler.java:184)
	at org.eclipse.emf.cdo.internal.server.QueryManager$QueryContext.run(QueryManager.java:294)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	... 3 more


Re: CDO OCLQuery [message #1229851 is a reply to message #1229829] Fri, 10 January 2014 11:07 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 10.01.2014 11:07, schrieb Phil Wim:
> I thought it's kind of an EMFT. Sorry! Next question i will start in EMF Forum. :)
>
> My source code was right, though. I simply forgot the missing ">".
> This is my code:
>
> CDOQuery cqo = transaction.createQuery("ocl","Composite.allInstances()->size()"); int result = cqo.getResultValue();
>
> I receive following exception:
>
> Exception in thread "main" org.eclipse.net4j.signal.RemoteException: java.lang.Error: Not supported
> at org.eclipse.net4j.signal.RequestWithConfirmation.getRemoteException(RequestWithConfirmation.java:141)
> at org.eclipse.net4j.signal.RequestWithConfirmation.setRemoteException(RequestWithConfirmation.java:130)
> at org.eclipse.net4j.signal.SignalProtocol.handleRemoteException(SignalProtocol.java:465)
> at org.eclipse.net4j.signal.RemoteExceptionIndication.indicating(RemoteExceptionIndication.java:66)
> at org.eclipse.net4j.signal.Indication.doExtendedInput(Indication.java:57)
> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
> at org.eclipse.net4j.signal.Indication.execute(Indication.java:51)
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:253)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:149)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:744)
> Caused by: java.lang.Error: Not supported
> at org.eclipse.emf.cdo.server.ocl.CDOExtentCreator$Lazy$1.size(CDOExtentCreator.java:392)
The OCLQueryHandler uses lazy extents by default. That means that the OCL interpreter can already start using the extent
before it's fully populated. But this means that the size of the extent may not be known at that time. If your query
needs to know the size of the allInstances() set (which triggers the CDOExtentCreator) you need to tell the query
handler not to use lazy extents:

cqo.setParameter("cdoLazyExtents", false);

I've added a note to the wiki.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



> at org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:547)
> at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:390)
> at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(AbstractEvaluationVisitor.java:248)
> at org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(QueryImpl.java:152)
> at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.evaluate(OCLQueryHandler.java:233)
> at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.executeQuery(OCLQueryHandler.java:184)
> at org.eclipse.emf.cdo.internal.server.QueryManager$QueryContext.run(QueryManager.java:294)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> ... 3 more
>
>


Re: CDO OCLQuery [message #1229858 is a reply to message #1229851] Fri, 10 January 2014 11:31 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Hi Eike,

Thanks so much. Now it works.

Is there any good startingpoint for learning cdo-olc-querys?

I directly ran into another problem. I was able to get the size of all objects by calling
CDOQuery cqo = transaction.createQuery("ocl",
            		"Composite.allInstances()");
                       
List<Composite> result = cqo.getResult(Composite.class);

System.out.println(result.size());


But when I try to iterate the List I receive following error:
Exception in thread "main" java.lang.ClassCastException: org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl cannot be cast to Package.Composite
	at com.jpw.erp.emf.client.RunCdo.popola(RunCdo.java:113)
	at com.jpw.erp.emf.client.RunCdo.main(RunCdo.java:31) 


Sorry for bothering so much

Philippe
Re: CDO OCLQuery [message #1229877 is a reply to message #1229858] Fri, 10 January 2014 12:29 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 10.01.2014 12:31, schrieb Phil Wim:
> Hi Eike,
>
> Thanks so much. Now it works.
> Is there any good startingpoint for learning cdo-olc-querys?
Probably by looking at the source code of OCLQueryHandler. I'm not aware of respective documentation other than the one
from Marco, which you've already found. Please feel free to add your findings to it!

>
> I directly ran into another problem. I was able to get the size of all objects by calling CDOQuery cqo =
> transaction.createQuery("ocl",
> "Composite.allInstances()");
> List<Composite> result = cqo.getResult(Composite.class);
>
> System.out.println(result.size());
I think with this code you actually load all Composites, which might be too much if you only need their number.

> But when I try to iterate the List I receive following error:
>
> Exception in thread "main" java.lang.ClassCastException: org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl
> cannot be cast to Package.Composite
> at com.jpw.erp.emf.client.RunCdo.popola(RunCdo.java:113)
> at com.jpw.erp.emf.client.RunCdo.main(RunCdo.java:31)
That looks like a standalone Java program so you need to initialize EMF's global package registry manually and early:

CompositePackage.eINSTANCE.getClass();

Are you using session.options().setGeneratedPackageEmulationEnabled(true) ?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> Sorry for bothering so much
> Philippe
>


Re: CDO OCLQuery [message #1229886 is a reply to message #1229877] Fri, 10 January 2014 13:00 Go to previous message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Thanks Eike!!

>That looks like a standalone Java program so you need to initialize EMF's global >package registry manually and early:
>
> CompositePackage.eINSTANCE.getClass();
Indeed i was testing in standalone. Now i'm up and running.

>Are you using session.options().setGeneratedPackageEmulationEnabled(true) ?
No. Don't know how or when i should use it.

Thanks so far..

Previous Topic:CDO as ECP Model Repository
Next Topic:[EMF Client Platform] create standalone product
Goto Forum:
  


Current Time: Fri Apr 19 13:35:17 GMT 2024

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

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

Back to the top