unable to get functions through java API - OrientDB 2.1.2

161 views
Skip to first unread message

Mihai Ocneanu

unread,
Sep 21, 2015, 5:02:41 AM9/21/15
to OrientDB
Hello,

I'm trying to run a JS function from within the java API, like so:

ODatabaseDocumentTx odbTx = oPartitionedDatabasePool.acquire();
OFunction function = odbTx.getMetadata().getFunctionLibrary().getFunction("functionName");
Number result = (Number)function.execute(userId);

The trouble is
odbTx.getMetadata().getFunctionLibrary()
gives me an empty function library.

Of course, I can access and run the functions from within studio without any issues.

Any idea what I'm doing wrong?

Thanks,
Mihai

Hrishikesh Khanapure

unread,
Dec 18, 2015, 4:47:20 AM12/18/15
to OrientDB
Hi,

Any update on this?
I am also unable to access function through Java API

Hrishikesh Khanapure

unread,
Dec 18, 2015, 4:47:20 AM12/18/15
to OrientDB
I ran into same situation.I was not able to access functions written in orientdb through java api but I found solution.Here is a piece of code that worked very well.

ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/test").open("admin", "admin");
Integer result = db.command(new OCommandFunction("testfunc")).execute(1,2);

But I am still wondering the below code should have worked because the same has given in orientdb doc.
ODatabaseDocumentTx odbTx = oPartitionedDatabasePool.acquire();
OFunction function = odbTx.getMetadata().getFunctionLibrary().getFunction("functionName");
Number result = (Number)function.execute(userId);

Need clarity on this.

On Monday, 21 September 2015 14:32:41 UTC+5:30, Mihai Ocneanu wrote:

Harish

unread,
Feb 24, 2016, 7:53:17 PM2/24/16
to OrientDB
I'm seeing the same thing as well. By default, the function library in the metadata is empty on acquiring ODatabaseDocumentTx from the pool. Just checked on Orient 2.2 beta, but the problem probably exists earlier as well.

If I make an extra call such as:

odbTx.getMetadata().getFunctionLibrary().load();

then the function library finally gets populated with the function names. But this is inefficient to do every time especially in the pooling scenario. 

This appears to be a bug, The function library should be populated as soon as the dbtx is acquired.

Harish

unread,
Feb 25, 2016, 2:15:20 PM2/25/16
to OrientDB
Reply all
Reply to author
Forward
0 new messages