查询节点的时候返回对象正常,但是查询关系返回的是null
@Repository
public interface RelationRepository extends GraphRepository<Relation> {
@Query("MATCH (m)-[r:Relation]->(a) RETURN r limit 1")
String findRelation();
}
3 个解决方案
#1
package com.neo.repository;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.neo.entity.relationships.Relation;
@Repository
public interface RelationRepository extends GraphRepository<Relation> {
@Query("MATCH (m)-[r:Relation]->(a) RETURN r limit 1")
Relation findRelation();
}
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.neo.entity.relationships.Relation;
@Repository
public interface RelationRepository extends GraphRepository<Relation> {
@Query("MATCH (m)-[r:Relation]->(a) RETURN r limit 1")
Relation findRelation();
}
#2
在网页上看数据库的Table,有时查询结果很多,graph只显示一个
#3
你描述的不是很清楚,如果说符合条件的节点很多你只查出来一个结果的话,一般是查询语句的问题。
#1
package com.neo.repository;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.neo.entity.relationships.Relation;
@Repository
public interface RelationRepository extends GraphRepository<Relation> {
@Query("MATCH (m)-[r:Relation]->(a) RETURN r limit 1")
Relation findRelation();
}
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.neo.entity.relationships.Relation;
@Repository
public interface RelationRepository extends GraphRepository<Relation> {
@Query("MATCH (m)-[r:Relation]->(a) RETURN r limit 1")
Relation findRelation();
}
#2
在网页上看数据库的Table,有时查询结果很多,graph只显示一个
#3
你描述的不是很清楚,如果说符合条件的节点很多你只查出来一个结果的话,一般是查询语句的问题。