我有以下关系
图-有很多连接 连接-有很多MoveablePoints
我正在使用neo4j的neo4j omg存储库接口v3.1.3来持久添加和删除连接和可移动点。我的单元测试工作正常,但是,如果在Web环境中使用它,则不会删除连接。
我正在使用5的可变深度持久性。我觉得这与omg会话有关,但我不确定。任何想法都将受到欢迎。
服务代码
@Transactional
@Override
@Retryable(value = TransientException.class,exceptionExpression="#{message.contains('RWLock')}", maxAttempts = 5)
public Diagram update(Diagram diagram) throws GUMLException {
// for (Connection connection : diagram.getConnections())
// if (connection.getId() != null)
// connectionService.deleteMoveablePoints(connection.getId());
//
// for (DiagramElement de : diagram.getDiagramElements()) {
// diagramElementService.save(de);
// }
return umlDiagramRepository.save(diagram, 5);
}
域类
@NodeEntity
public class Diagram {
public Set<Connection> getConnections() {
if (connections == null)
connections = new HashSet<Connection>();
return connections;
}
public void setConnections(Set<Connection> connections) {
this.connections = connections;
}
@org.neo4j.ogm.annotation.Relationship(type = "HasConnections", direction = org.neo4j.ogm.annotation.Relationship.OUTGOING)
Set<Connection> connections;
}
@NodeEntity
public class Connection implements IConnector {
public Set<MoveablePoint> getMoveablePoints() {
return moveablePoints;
}
public void setMoveablePoints(Set<MoveablePoint> moveablePoints) {
this.moveablePoints = moveablePoints;
}
@org.neo4j.ogm.annotation.Relationship(type = "HasMoveablePoints", direction = org.neo4j.ogm.annotation.Relationship.OUTGOING)
private Set<MoveablePoint> moveablePoints;
}
当我更改服务代码以首先从会话中检索对象然后覆盖时,它似乎起作用了。不过,这对我来说似乎不正确。
Diagram d2 = umlDiagramRepository.findById(diagram.getId()).get();
d2 = diagram;
return umlDiagramRepository.save(d2, 5);