Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Parametrized queries #1419

Closed
vicpara opened this Issue Apr 1, 2013 · 2 comments

Comments

Projects
None yet
4 participants

vicpara commented Apr 1, 2013

I am trying to execute a parametrized query according to the info from https://code.google.com/p/orient/wiki/DocumentDatabase#Prepared_query but I constantly get an error at the command parsing operation.
Using OrientDB v 1.3.0, Java JRE 1.7.0 amd64.

Here are some examples

Example 1:

OSQLSynchQuery<ODocument> cmd = new OSQLSynchQuery<ODocument>("SELECT * FROM (traverse V.out, E.in from ? ) ORDER BY @rid ASC");
List<ODocument> result = database.query(cmd, vertex.getIdentity());
        // List<ODocument> result = database.command(cmd).execute(vertex.getIdentity()); // same exception

Error on parsing query
Query:  ?
------^

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:515)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:470)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:59)
    at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1832)
    at com.orientechnologies.orient.client.remote.OStorageRemote.command(OStorageRemote.java:999)
    at com.orientechnologies.orient.client.remote.OStorageRemoteThread.command(OStorageRemoteThread.java:241)
    at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
    at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:78)
    at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:32)
    at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.query(ODatabaseRecordAbstract.java:447)
    at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.query(ODatabaseRecordWrapperAbstract.java:187)

Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Class '?' was not found in current database
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:517)
    ... 18 more

Example 2
I've tried to replace <v_id> with :<v_id> , ? or just :v_id... same exception.

HashMap<String, Object> params = new HashMap<String, Object>();
params.put("v_id", vertex.getIdentity());

OSQLSynchQuery<ODocument> cmd = new OSQLSynchQuery<ODocument>("SELECT * FROM (traverse V.out, E.in from <v_id> ) ORDER BY @rid ASC");
List<ODocument> result = database.command(cmd).execute(params);


Exception: 
Error on parsing query at position #6: Error on parsing query
Query:  <v_id>
-----------^

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:515)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:470)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:59)
    at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1832)
    at com.orientechnologies.orient.client.remote.OStorageRemote.command(OStorageRemote.java:999)
    at com.orientechnologies.orient.client.remote.OStorageRemoteThread.command(OStorageRemoteThread.java:241)
    at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
    at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:78)
    at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:32)

Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Class 'V_ID' was not found in current database
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:517)
    ... 16 more

Not sure but most probably linked to nuvolabase#1399. Luca can confirm.

@lvca lvca added the enhancement label Oct 3, 2014

@lvca lvca added this to the 2.1 milestone Oct 3, 2014

Contributor

luigidellaquila commented Feb 27, 2015

fixed in 2.1 snapshot (develop branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment