I'm working on some Java code to interact with OrientDB graphs. Currently I'm looking at the interface for OCommandRequest. The method execute() can return something different based on the query that we run... but I'm not sure what is possible from it.
I have looked at the code, but I'm somehwhat new to Java. So far I see that OCommandRequest is an interface but that's about as far as I've gone pulling the thread in the code.
I haven't found a lot in the OrientDB Documentation that has helped me to know what return types are possible and what the values mean when they get returned.
I played with some examples on my end based on some of the examples I found at massapi. Sometimes it returns an Integer, other times a Boolean, and yet other times I've gotten back an Iterable.
My question is: Is there some documentation available that characterizes what OCommandRequest.execute() returns and why? Ideally some formatted docs are nice, but pointers into the code to find where the interface is being implemented would also be helpful and allow me to pull the thread a little bit more.
For now, I'm emulating one of the examples from the massapi site I linked earlier (but I'm not sure if this is really considered the blessed way to handle responses from queries):
OCommandRequest command = graph.command(new OCommandSQL(query));
Object result = command.execute();
if( result instanceof Integer ) {
// do stuff if an integer was returned
} else if( result instanceof Boolean ) {
// do stuff if a boolean was returned
} else if( result instanceof Iterable<OrientVertex> ) {
// do stuff if an iterable list of vertices was returned
} else {
// any other types?
}
Any pointers that someone can give are definitely useful.
Thanks!
There is no documentation about that, it depends on SQL command you execute.
To know the return type you have to refer directly to their own class. For eg. DROP CLASS
returns Boolean, and so on.
Anyway you can use this code to see the return type:
OCommandRequest command = g.command(new OCommandSQL(q));
Object result = command.execute();
System.out.println(q+"\n"+result.getClass().toString()+"\n");