Spring Data Neo4j中的Cypher查询与Cypher DSL [英] Cypher query vs cypher dsl in spring data neo4j

查看:476
本文介绍了Spring Data Neo4j中的Cypher查询与Cypher DSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解Spring数据neo4j框架中的neo4j dsl建议.
到目前为止,我曾经创建从GraphRepositoryNamedIndexRepository等扩展的存储库接口,并使用带有@Query批注的自定义密码查询编写自定义方法,如下所示:

I want to know about neo4j dsl recommendation in Spring data neo4j framework.
As of now I used to create repository interface extending from GraphRepository,NamedIndexRepository etc. and write my custom methods with my custom cypher query with @Query annotation as below:

@Query(value="START root=node:__types__(className='com.data.EntityNode') WHERE root.id={0} and "
        + "root.type={1} return root")  
T findByIdAndType(String id, String type);  

就我认为静态查询而言,上述方法很好地工作.但是现在我需要使用其他方式,根据我的需要生成密码查询!然后我遇到了 neo4j dsl 库,它看起来像是解决我的需求的方法.
ref: link-1 链接2

above method works nicely as far as I consider the static query. but right now I am in need to use some other way where I can generate cypher query depending upon my need !. then I came across neo4j dsl library which looks like a solution to my requirement.
ref: link-1 link-2

我的问题是:

  1. 在Spring数据neo4j中使用neo4j dsl lib是否可以(我正在使用v2.1.0 RELEASE)?或
  2. 对于给定的情况,还有其他方法可以在spring数据neo4j中生成动态密码查询吗?还有更多有趣的
  3. 是否可以从密码dsl生成查询并将其传递到我的自定义存储库接口,执行它们并获得结果(我的意思是@Query值)?因为如果是的话,那么我不必在现有设计中进行重大更改.
  1. is it OK to use neo4j dsl lib in Spring data neo4j (I am using v2.1.0 RELEASE) ? or
  2. is there any other way to generate dynamic cypher query in spring data neo4j for given set of situation ? and more interesting
  3. is it possible to generate query from cypher dsl and pass it to my custom repository interface, execute them and get result (I mean @Query value)? because if yes then I dont have to add major changes to my existing design.

谢谢

推荐答案

  1. 更新到3.0.1.RELEASE
  2. 可以使用密码DSL
  3. 由于注释是编译时,而Cypher DSL是运行时,您不能在那里使用它们,但是
  4. 您可以从CypherDSLRepository继承,这会向您的存储库添加一些不错的方法

这篇关于Spring Data Neo4j中的Cypher查询与Cypher DSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆