neo4j - Set类型的可变深度持久性和关系
问题描述
我有以下关系
图 -has-many- Connection Connection -has-many 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);
解决方案
推荐阅读
- gis - 如何正确地将 GIS shapefile 转换为道路网络?
- python - 星号 * 作为函数/类/方法签名中的第一个参数是什么意思?
- python - python以不同形式打印向量
- operating-system - 如果前一个进程使用 DMA 切换到新进程时操作系统和 DMA 会做什么
- python - 出现错误 403:尽管使用了标头,但仍被禁止。可能出了什么问题?
- javascript - 点击缩略图和滑块的图像预览:如何使点击和滑动协同工作?
- debugging - 有没有办法用它在 vscode 中编译的 asm 来单步执行 Rust 代码?
- javascript - 控制台中的困惑或如何通过查看项目是否为未定义的数据类型或未定义的字符串来查找,Google 是否应该改进字符串控制台?
- flutter - 单击 Navigator.pop() 时出现黑屏
- android - 我需要从看起来像数组的 jsonobject 获取数据,但我只需要最后一个值,