Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

orientdb: passing an Array to a query using 'IN' on an OType.LINKLIST field

I'm trying to pass an array of Category POJOs to the query using IN in the SQL:

public ShareObject[] search(String name, Category[] categories) {
...
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM ShareObject WHERE name LIKE ? AND categories IN ?");
List<ODocument> result = db.command(query).execute(name, categories);

This will return an empty list. If I change the SQL to the following I get a result:
"SELECT FROM ShareObject WHERE name LIKE ? AND categories IN [#10:0,#10:1]"

I also tried this, without sucess:

OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM ShareObject WHERE name LIKE ? AND categories IN ?");
List<ODocument> result = db.command(query).execute(name, new String[] { "#10:0", "#10:1" });
  • How do I have to pass the array to the query, IDs or objects?
  • Do I have to change the SQL statement?
  • Is this even possible?
like image 973
flavio.donze Avatar asked Dec 21 '15 07:12

flavio.donze


1 Answers

Try this code:

OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM ShareObject WHERE name like ? AND categories IN (?)");
List<ODocument> result = db.command(query).execute(name,"[#10:0,#10:1]");
like image 133
Alessandro Rota Avatar answered Sep 29 '22 06:09

Alessandro Rota