Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Parametrized queries #1419

Closed
vicpara opened this Issue · 2 comments

4 participants

@vicpara

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 with : , ? 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
@thedeveloperdude

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

@luigidellaquila luigidellaquila was assigned by lvca
@lvca lvca added the enhancement label
@lvca lvca added this to the 2.1 milestone
@luigidellaquila
Collaborator

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
Something went wrong with that request. Please try again.