Skip to content

Commit

Permalink
fix(starter-data-neo4j) 使用cypher语法查询
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhengjiaao committed Nov 14, 2022
1 parent 616c661 commit b22fc7b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import com.zja.entity.User;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
* Company: 上海数慧系统技术有限公司
Expand All @@ -12,4 +16,11 @@
* Desc:
*/
public interface UserRepository extends Neo4jRepository<User, Long> {

/**
* 使用cypher语法查询 自定义查询
*/
@Query("MATCH (n:User) where n.name contains $name RETURN n")
List<User> getUserByName(@Param("name") String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public void test2() {
System.out.println(userList);
}

@Test
public void test3() {
List<User> userList = userRepository.getUserByName("李四");
System.out.println(userList);
}

@Test
public void deleteAllTest() throws Exception {
//仅删除所有的User,不会删除Phone
Expand Down

0 comments on commit b22fc7b

Please sign in to comment.