1. @Query query method
1.1 Fuzzy query
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] multi-id query
/**
* 根据以下两个方法的测试和对比,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);
Return to various nodes haha, if it is helpful to you, please give a thumbs up!!! ( ▽ )