Querying issue

149 views
Skip to first unread message

Andrey Yesyev

unread,
Feb 14, 2014, 3:33:55 PM2/14/14
to orient-...@googlegroups.com
Hi there,

Trying to query DB using this function

    public Iterable<Vertex> findCollectionVertex(Collection c){
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("select from (traverse out_HAS from (select from Case where name = :cname ) while $depth <= 1) where name = :name");
        Map<String,Object> params = new HashMap<>();
        params.put("cname", c.getCase().getName());
        params.put("name", c.getName());

        Iterable<Vertex> list =  graph.command(query).execute(params);
        return list;
    }


 list is always empty. However I run the same query in Orient Studio with parameters in query

select from (traverse out_HAS from (select from Case where name = 'demo' ) while $depth <= 1) where name = 'telnet_cat_emial_list.pcap'

and have expected results

@rid@version@classnamein_HAS
#13:32Collectiontelnet_cat_emial_list.pcap[1]
Any ideas why this can happen !?

-Andrey

Andrey Yesyev

unread,
Feb 14, 2014, 4:13:11 PM2/14/14
to orient-...@googlegroups.com
Ok,
I got rid of parameters

OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("select from (traverse out_HAS from (select from Case where name = 'demo') while $depth <= 1) where name = 'telnet_cat_emial_list.pcap'");

Query does return a result.

I changed it to unnamed parameters

        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("select from (traverse * from (select from Case where name = ? ) while $depth <= 1) where name = ?");
            List<ODocument> docs = graph.getRawGraph().command(query).execute(c.getCase().getName(), c.getName());

and it's even worse, I got an exception

Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select from (traverse * from (select from Case where name = ? ) while $depth <= 1) where name = ?
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:102)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:85)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:82)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:29)
at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1320)
at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:330)
at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:125)
at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:45)
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.bindParameters(OSQLPredicate.java:358)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.assignTarget(OCommandExecutorSQLResultsetAbstract.java:135)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.assignTarget(OCommandExecutorSQLSelect.java:354)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.executeSearch(OCommandExecutorSQLSelect.java:328)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:313)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:57)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:96)
... 8 more

This doesn't seem right to me.

Andrey Yesyev

unread,
Feb 14, 2014, 4:43:38 PM2/14/14
to orient-...@googlegroups.com
Trying to narrow the area of issue.

I ran this query

        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("select from Case where name = :cname");
        Map<String, String> params = new HashMap<>();
        params.put("cname", c.getCase().getName());
                List<ODocument> docs = graph.getRawGraph().command(query).execute(params);

And got a result. So, named parameters work.
Then, I ran these queries

        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("traverse * from (select from Case where name = :cname");
        Map<String, String> params = new HashMap<>();
        params.put("cname", c.getCase().getName());
            List<ODocument> docs = graph.getRawGraph().command(query).execute(params);

        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>("traverse * from (select from Case where name = ?");
        List<ODocument> docs = graph.getRawGraph().command(query).execute("demo");


And didn't get any result. No exceptions though. However if I substitute named parameter with just a value, it returns a result.
So, I presume, there is a problem with named/unnamed parameters when traverse is around.

Damian Bronecki

unread,
Feb 15, 2014, 2:02:34 AM2/15/14
to orient-...@googlegroups.com
This is known issue with parameters in nested queries.

Take a look here:
https://github.com/orientechnologies/orientdb/issues/1069

Andrey Yesyev

unread,
Feb 15, 2014, 7:41:16 AM2/15/14
to orient-...@googlegroups.com

Thanks Damian!
Wow, it's a year old bug. Any plans on fixing it!?

--
 
---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/gtf6FbAFhL4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages