Spring Data Neo4j中的Cypher查询与Cypher DSL [英] Cypher query vs cypher dsl in spring data neo4j
问题描述
我想了解Spring数据neo4j框架中的neo4j dsl建议.
到目前为止,我曾经创建从GraphRepository
,NamedIndexRepository
等扩展的存储库接口,并使用带有@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
我的问题是:
- 在Spring数据neo4j中使用
neo4j dsl
lib是否可以(我正在使用v2.1.0 RELEASE)?或 - 对于给定的情况,还有其他方法可以在spring数据neo4j中生成动态密码查询吗?还有更多有趣的
- 是否可以从密码dsl生成查询并将其传递到我的自定义存储库接口,执行它们并获得结果(我的意思是
@Query
值)?因为如果是的话,那么我不必在现有设计中进行重大更改.
- is it OK to use
neo4j dsl
lib in Spring data neo4j (I am using v2.1.0 RELEASE) ? or - is there any other way to generate dynamic cypher query in spring data neo4j for given set of situation ? and more interesting
- 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.
谢谢
推荐答案
- 更新到3.0.1.RELEASE
- 可以使用密码DSL
- 由于注释是编译时,而Cypher DSL是运行时,您不能在那里使用它们,但是
- 您可以从CypherDSLRepository继承,这会向您的存储库添加一些不错的方法
这篇关于Spring Data Neo4j中的Cypher查询与Cypher DSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!