尊敬的 Spring 社区成员:
我们很高兴地宣布,支持 Neo4j 的 Spring Data Graph 项目的第二个版本 (1.1.0.RELEASE) 现已可用!
在 2011 年 4 月 Spring Data Graph 的首次公开发布后,我们主要关注了用户反馈。
通过围绕工具改进 文档 并升级 AspectJ 版本,我们解决了用户报告的许多 AspectJ 问题。使用最新的 STS 和 Eclipse,以及有望支持的 Idea11,现在可以开发没有红色波浪线(错误标记)的 Spring Data Graph 应用程序了。为了进一步简化开发,我们还提供了 ant/ivy 的示例构建脚本和 gradle 插件。
当然,我们跟上了 Neo4j 的开发步伐,目前使用了 Neo4j (1.4.1) 的最新稳定版本。
在 Neo4j 过去几个月的开发中,改进的查询支持(Cypher, Gremlin)是重要方面之一。因此,我们努力在所有层面支持它。现在,可以通过 Spring Data Graph Repositories、Neo4j-Template 执行 Cypher 查询,也可以作为动态字段注解的一部分并通过引入的实体方法执行。Gremlin 脚本也是如此。这种新的表达能力能做些什么呢?让我们来看一下。
例如,在一个 repository 中
public interface PersonRepository extends GraphRepository, NamedIndexRepository {
@Query("start team=(%team) match (team)-[:persons]->(member) return member")
Iterable findAllTeamMembers(@Param("team") Group team);
@Query(value = "g.v(team).out('persons')", type = QueryType.Gremlin)
Iterable findAllTeamMembersGremlin(@Param("team") Group team);
}
Neo4j Template API 进行了全面改进,从而方法更少、更专注。高级查询结果处理能力(类型转换、映射、单结果、handler 等)现在使用更流畅的 API 实现。这个新 API 适用于所有类型的查询,无论是索引查找、图遍历、Cypher 查询还是 Gremlin 脚本。
template.query("start n=(0) match n-->m return m", null).to(Node.class);
template.execute("g.v(0).out", null).to(Node.class);
template.lookup("relationship", "name", "rel1").to(String.class, new PropertyContainerNameConverter()).single();
template.traverse(referenceNode, traversalDescription).handle(new Handler<Path>() {
public void handle(Path value) {
final String name = (String) value.endNode().getProperty("name", "");
resultSet.add(name…