Cypher query vs cypher dsl in spring data neo4j

╄→尐↘猪︶ㄣ 提交于 2020-01-16 19:18:08

问题


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);  

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

My question is:

  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.

Thanks


回答1:


  1. Update to 3.0.1.RELEASE
  2. It is ok to use cypher DSL
  3. As annotations are compile time and Cypher DSL is runtime you cannot use them there, but
  4. you can inherit from CypherDSLRepository which adds some nice methods to your repository


来源:https://stackoverflow.com/questions/22989614/cypher-query-vs-cypher-dsl-in-spring-data-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!