Regarding Function calling from Java client

26 views
Skip to first unread message

Sourish Dasgupta

unread,
Jul 14, 2015, 5:00:14 AM7/14/15
to orient-...@googlegroups.com
Hi,

I have a different question. It seems that a function written in javascript when called by a java client returns Object. In that case, I do not see how this code, given in the documentation, makes sense in terms of type compatibility:

ODatabaseDocumentTx db = new ODatabaseDocumentTx("local:/tmp/db");
db.open("admin", "admin");
OFunction sum = db.getMetadata().getFunctionLibrary().getFunction("sum");
Number result = sum.execute(3, 5);
Can you please explain the last line? How can a Number variable refer to an Object instance? It might be so that I am mistaken grossly somewhere. 

I also find that we might be able to write a Java function in Orientdb provided we connect that with the SQL Engine. Is there a way to use OFunction object (in a similar way as for JS functions), instead of SQL query shooting, to execute the function?

Regards,

Sourish

Giulia Brignoli

unread,
Jul 14, 2015, 5:27:35 AM7/14/15
to orient-...@googlegroups.com
Hi Sourish,

For the first question, you have to cast instruction "sum.execute(3, 5)" of type Number (like this: (Number) sum.execute(3, 5) , because otherwise you will get an error.

However, for the second question it isn't very clear what would you do, can you explain better? 

Bye, 
Giulia
Reply all
Reply to author
Forward
0 new messages