2016-03-20 3 views
0

OrientDBを使って実験する 関数からインスタンスの関数へのリンクを実行しようとしています。リンクされたOF関数を実行する

"testFunction"と@rid#6:2という名前のOFunctionインスタンスがあります。

私のクラスには、プロパティを持っています

create property MyClass.myFunction LINK OFunction 

私のインスタンスされています。今、私は私のインスタンスを選択し、そのリンク機能を実行HTTP REST実行可能な関数を作成したい

insert into MyClass set myFunction = #6:2 

は私が

db.query('select from MyClass limit 1')[0].field('myFunction'); 

"@type": "d", 
    "@rid": "#6:2", 
    "@version": 1, 
    "@class": "OFunction", 
    ... 

に正しく結果がどのようにこの参照によってそれを実行することを参照してください?

私はそれがで名前によって実行することができます知っている:

db.getMetadata().getFunctionLibrary().getFunction("test1").execute(); 

しかし、それは文字列で機能を検索するために意味をなさない。

ありがとうございます。

答えて

0

あなたは

String query="select myFunction.name as name from MyClass limit 1"; 
Iterable<ODocument> it=db.command(new OCommandSQL(query)).execute(); 
if(it.iterator().hasNext()){ 
ODocument doc1=it.iterator().next(); 
    String name=doc1.field("name"); 
    Iterable<ODocument> it2=db.command(newOCommandFunction(name)).execute(); 
    for(ODocument doc2:it2){ 
     System.out.println(doc2.getIdentity()); 
     } 
} 

はそれが

+0

を役に立てば幸い、このコードを使用することができる提案をいただき、ありがとうございます。しかし、私はnewOCommandFunction(name)のような名前を使わずに関数を参照で呼び出そうとしています。 – AlexV

関連する問題