|
|
|
Re: CDO OCLQuery [message #1229851 is a reply to message #1229829] |
Fri, 10 January 2014 11:07 |
|
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
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: CDO OCLQuery [message #1229877 is a reply to message #1229858] |
Fri, 10 January 2014 12:29 |
|
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
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.01544 seconds