spring data neo4j的@Query等查询方式模糊查询

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哈哈,如果对诸君有帮助,随手点个赞哦!!!()

猜你喜欢

转载自blog.csdn.net/weixin_42096620/article/details/110245755