Potential bug with OSQL when combined with Java

42 views
Skip to first unread message

K Major

unread,
Apr 18, 2016, 12:12:15 PM4/18/16
to OrientDB
Hello,

I have identified a strange behavior when using OSQL inside Java. Maybe I'm doing something wrong ... 

Problem : The operators >,<, >=, <= don't seem not to work when used in OSQL embedded in Java 

Following graph
Nodes: 
v(Person)[#11:0]:name=1, age=71, 
v(Person)[#11:1]:name=2, age=59, 

Edges :
1 --> 2 (knows) weight=272,  id = #12:0
1 --> 3 (knows) weight=437,  id = #12:1

CODE :
String query = "";

it
=((Iterable<Vertex>)graphDb.command(new OSQLSynchQuery<Vertex>(query)).execute(1)).iterator();
 
OrientVertex res;
 
while(it.hasNext()){
 res
= (OrientVertex) it.next();
 
System.out.println((Integer)res.getProperty("name"));
 
}



QUERY : 

I want to retrieve neighbors of a node having name = 1 such that the edge has a weight property greater than a certain value :


select expand(outE().in()) from Person where name=?
== > Return 2 and 3


select expand(outE()[weight = 272].inV()) from Person where name=?
== > Return 2


select expand(outE()[weight >= 272].inV()) from Person where name=?

== > Returns nothing !! Should return 2 and 3









Luigi Dell'Aquila

unread,
Apr 18, 2016, 12:23:17 PM4/18/16
to orient-...@googlegroups.com
Hi,

Which version of OrientDB are you using? We fixed a similar problem a few hotfix releases ago

Thanks

Luigi


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

K Major

unread,
Apr 19, 2016, 10:32:39 AM4/19/16
to OrientDB
Indeed, I changed from 2.1.11 to 2.1.15 and it fixed the problem, thanks !


One small question : is it possible to retrieve the result of a query in the form of list and not nodes containing the result ? 

Ivan Mainetti

unread,
Apr 19, 2016, 11:06:44 AM4/19/16
to OrientDB
Hi,

you mean in studio, console, java or what?
Seeing your question I think you're using java, so you need a method to convert the Iterable object into a List, is it correct?

K Major

unread,
Apr 19, 2016, 1:24:53 PM4/19/16
to OrientDB
Yes, in java.

I can iterate through all the nodes and then create a list from it but that would be not really efficient.

I was wondering if there is a way/fonction that directly gives me a list or even hashmap containing all the columns ?

Ivan Mainetti

unread,
Apr 19, 2016, 3:24:24 PM4/19/16
to OrientDB
oh well, I don't think such a feature is available by default.
If you really need a List you'll have to iterate the Iterator to fill it.
Reply all
Reply to author
Forward
0 new messages