spent multiple days trying figure out why isn't working. model player-[:played_with_team]->team-[:contested_in]->league
. few instances of relation follows
bob-[:played_with_team]->falcons-[:contested_in]->abc league alice-[:played_with_team]->falcons-[:contested_in]->abc league bob-[:played_with_team]->falcons-[:contested_in]->xyzleague
bob played same team "falcons" in 2 leagues abc , xyz. fact want capture. since bob played same team in 2 different leagues, need have 2 played_with_team relations between same start (bob) , end (falcons) nodes.
i using spring data , have entities defined. able create 2 such relationships not more 2 using spring data. i.e. if bob played same team falcons 3rd league, unable create 3rd relation. not sure problem is. below code creating new relation. playedwith relationshipentity
player
start node , team
end node.
private playedwith createplayedwithrelation(league currentleague, team team, player p) { system.err.println("creating played_with_team relation between " + team + " , " + p + " , " + currentleague); playedwith playedwith = template.createrelationshipbetween(p, team, playedwith.class, "played_with_team", true); playedwith.setduring(currentleague.getstartdate()); playedwith.setinleague(currentleague); playedwith.setplayer(p); playedwith.setteam(team); playedwith.setascaptain(p.iscaptain()); team.addplayer(p); template.save(playedwith); return playedwith; }
playedwith
@relationshipentity (type = "played_with_team") public class playedwith { @graphid private long nodeid; @startnode player player; @fetch @endnode team team; }
let me know if there alternate way of storing scenario.
you not need add relationship between bob , falcons between falcons , new league this:
(falcons)-[:contested_in]->(newleague)
as bob plays falcons , falcons contested in abc league, xyz league , new league bob implicitly plays in 3 leagues.