王行天文
王行天文

Reputation: 1

spring data neo4j could not query a list of relationship?

i am using neo4j to query some nodes and relationships, in my CQL,if i return the numbers of relationships, i can find 13,it means the data has 13 relations,but if i return like 'RETURN r' or 'RETURN collect(r) as relationList',the code returns null, this bug comfused me all day .anyone can helps me,please? And sorry for my English, i am not a native speaker here are my codes:

@NodeEntity(label = 'colDataAssest')
public class ColDataAssest implements Serializable{
@Id
@GeneratedValue
private Long id;
@Property
private String colId;
}
@RelationshipEntity(type = 'colRelationship')
public class ColAssestRelationship{
@Id
@GeneratedValue
private Long id;
@StartNode
private ColDataAssest parent;
@EndNode
private ColDataAssest children;
@Property
private String relation;
}
@Repository
public interface ColAssestRepository extends Neo4jRepository<ColDataAssest,Long>{
@Query("match (node:colDataAssest)-[r:colRelationship]-(root:colDataAssest {colId:$colId}) 
return r")
List<ColAssestRelationship> findRelationByColid(@Param("colId")String colId);

@Query("match (node:colDataAssest)-[r:colRelationship]-(root:colDataAssest {colId:$colId}) 
return count(r)")
int countRelationByColid(@Param("colId")String colId);
}
List<ColAssestRelationship> relationList = ColAssestRepository.findRelationByColid(col);//null
int num = countRelationByColid(col);//13

i just want to get a list of all the relations

Upvotes: 0

Views: 35

Answers (0)

Related Questions