1. @Query查询方式
1.1 模糊查询
public interface BaseNodeRepository extends Neo4jRepository<BaseNode, Long> {
@Query("MATCH (n) WHERE n.name =~ ('.*'+$name+'.*') RETURN n")
List<BaseNode> findBaseNodeByNameLike(String name);
}
1.2 id in [1, 2, 3] 多id查询
/**
* 根据以下两个方法的测试和对比,findBaseNodesByIdIn这种方式查询返回的结果不能是抽象类,必须有 @NodeEntity
* @Query方式查询的就不许要那种方式...
* @param ids
* @return
*/
@Query("match (n) where id(n) in $ids return n")
List<BaseNode> findByNodeIds(Collection<Long> ids);
// 查询不出来...
List<BaseNode> findBaseNodesByIdIn(Collection<Long> ids);
返回各种各样的node哈哈,如果对诸君有帮助,随手点个赞哦!!!(▽)