我是 OrientDB 和蓝图的新手。我正在尝试使用 OrientDB Java API 执行简单的 MATCH 查询。下面是我的代码:
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);
}
}
当我运行时,它在 Vertices 中给了我 null。简单Select * from Person
的工作正常并且不返回空顶点。我使用的是 2.2.22 版本的 OrientDB。
任何链接或提示将不胜感激。谢谢!