2017-07-17 10 views
0

OrientDBと青写真を初めて使用しています。 OrientDB Java APIを使用して簡単なMATCHクエリを実行しようとしています。以下は私のコードです:Orientdb OCommandSQLとの一致がnullを返す。頂点

import com.orientechnologies.orient.core.sql.OCommandSQL; 
import com.tinkerpop.blueprints.TransactionalGraph; 
import com.tinkerpop.blueprints.Vertex; 
import com.tinkerpop.blueprints.impls.orient.OrientGraph; 

public class OrientApp { 

@SuppressWarnings("unchecked") 
public static void main(String[] args) { 

    TransactionalGraph graph = new OrientGraph("remote:localhost/GratefulDeadConcerts", "admin", "admin"); 
    /* 
    * Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph) 
    * .command(new OCommandSQL(
    * "MATCH {class: Person, as: liker} -likes- {class:Person, as: like},{as:liker} -living_in- {class: City, where: (name='Bangalore')},{as:like} -living_in- {class: City, where: (name='Delhi')} RETURN liker.name,like.name" 
    *)) .execute()); 
    */ 

    Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph) 
      .command(new OCommandSQL("MATCH {class: Person, as: person} RETURN person")).execute()); 

    /* 
    * Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph) 
    * .command(new OCommandSQL("select * from person")).execute()); 
    */for (Vertex v : vertices) { 
     System.out.println(v); 
    } 
    System.out.println(graph); 
} 

}

私はそれが頂点に私にはnullを与えて実行すると。 Select * from Personはうまくいき、ヌルの頂点を返さない。 OrientDBの2.2.22バージョンを使用しています。

リンクやヒントがあれば幸いです。ありがとう!

答えて

3

次のリンクは

http://useof.org/java-open-source/com.orientechnologies.orient.core.metadata.schema.OSchemaProxyが実際に我々がマッチクエリで$elementsを返す必要が便利です。次のコード

が働いた:

import com.orientechnologies.orient.core.sql.OCommandSQL; 
import com.tinkerpop.blueprints.TransactionalGraph; 
import com.tinkerpop.blueprints.Vertex; 
import com.tinkerpop.blueprints.impls.orient.OrientGraph; 

public class OrientApp { 

@SuppressWarnings("unchecked") 
public static void main(String[] args) { 

    TransactionalGraph graph = new OrientGraph("remote:localhost/GratefulDeadConcerts", "admin", "admin"); 
    Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph) 
      .command(new OCommandSQL("MATCH {class: Person, as: person, where: (age>10)} RETURN $elements")) 
      .execute()); 

    for (Vertex v : vertices) { 
     System.out.println(v.getProperty("age").toString()); 
    } 
    System.out.println(graph); 
} 
} 

は、それが誰かを助けることを願っています。ありがとう!

関連する問題