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);
}
}
當我運行它給我的頂點空。簡單的Select * from Person
工作正常,並返回非零頂點。我正在使用OrientDB的2.2.22版本。
任何鏈接或提示將不勝感激。謝謝!