Spring data neo4j : count relation By EndNode ID

﹥>﹥吖頭↗ 提交于 2019-12-13 07:46:32

问题


I'm using a spring data neo4j 5.0.0.

My model is a (user)-[:ATTEND]-(meeting) and ATTEND is a RelationshipEntity.
user have attend relationship, meeting does not have relationship.

@Relationship(type = "ATTEND")
Set<AttendMeeting> attendMeetings = new HashSet<>();

RelationshipEntity code.

@Setter @Getter @ToString
@NoArgsConstructor
@RelationshipEntity(type = "ATTEND")
public class AttendMeeting {
    @GraphId private Long id;
    @JsonIgnore
    @StartNode private User user;
    @EndNode private Meeting meeting;
}

So I just wannna attend count by meetingId.

Is it possible without Query?

when I run on repository.countByMeetingId method auto creation query is

MATCH (m:`Meeting`) WHERE m.`id` = { `meeting_id_0` } MATCH (n)-[r0:`ATTEND`]->(m) RETURN COUNT(r0)

I expect id(m) but generated query is m.`id'.

Can I make countByRelationShipEntityId?
How can I auto generate code like this.
MATCH ()-[r:ATTEND]-(m:Meeting) WHERE ID(m) = {0} RETURN COUNT (r)

Thanks for your answer and sorry for my poor English.


回答1:


There is currently (SDN 5.0.1) no possibility to count on a given object e.g. countByMeeting(Meeting meeting) or let SDN handle id as a special property. Please feel free to create an issue at https://jira.spring.io/browse/DATAGRAPH/

The only solution we can offer at the moment without providing a query is a count by related object property like countByMeetingName(String meetingName)

Edit: Issue created https://jira.spring.io/browse/DATAGRAPH-1049



来源:https://stackoverflow.com/questions/47132148/spring-data-neo4j-count-relation-by-endnode-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!