花了几天时间试图弄清楚为什么这不起作用。我的型号是Player-[:PLAYED_WITH_TEAM]->team-[:CONTESTED_IN]->league
。这种关系的几个例子如下
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 在 ABC 和 XYZ 两个联赛中为同一支球队“Falcons”效力。这是我想要捕捉的事实。由于 Bob 在 2 个不同的联赛中为同一支球队效力,我需要在同一个开始 (Bob) 和结束 (Falcons) 节点之间有两个 PLAYED_WITH_TEAM 关系。
我正在使用弹簧数据并定义了实体。我能够使用弹簧数据创建 2 个这样的关系,但不超过两个。即如果鲍勃为同一支猎鹰队效力于另一个第三联赛,我无法建立第三关系。我不确定问题出在哪里。下面是我创建新关系的代码。PlayedWith 是一个RelationshipEntity
作为Player
起始节点和Team
作为结束节点的节点。
private PlayedWith createPlayedWithRelation(League currentLeague, Team team, Player p)
{
System.err.println("Creating PLAYED_WITH_TEAM relation between " + team + " and " + p + " and " + 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;
}
玩过
@RelationshipEntity (type = "PLAYED_WITH_TEAM")
public class PlayedWith
{
@GraphId
private Long nodeId;
@StartNode
Player player;
@Fetch
@EndNode
Team team;
}
让我知道是否有另一种存储此场景的方法。