}
@Test
@Transactional
public void testUpdateSingleRelatedToViaField() {
Group group;
final Long firstMentorshipId;
final Person mentor2;
try (Transaction tx = neo4jTemplate.getGraphDatabaseService().beginTx()) {
group = persist(new Group());
group.setMentorship(new Mentorship(persist(new Person()), group));
persist(group);
firstMentorshipId = group.getMentorship().getId();
mentor2 = new Person();
group.setMentorship(new Mentorship(persist(mentor2), group));
persist(group);
tx.success();
}
final Node node = neo4jTemplate.getPersistentState(group);
assertEquals(1, IteratorUtil.count(node.getRelationships(Direction.INCOMING, DynamicRelationshipType.withName("mentors"))));
final Group loaded = neo4jTemplate.load(node, Group.class);
assertFalse(loaded.getMentorship().getId().equals(firstMentorshipId));
assertEquals(mentor2, group.getMentorship().getMentor());
assertEquals(group, group.getMentorship().getGroup());
}