Neo4j在添加新关系期间删除现有关系本身

Neo4j在添加新关系期间删除现有关系本身,neo4j,spring-data,spring-data-neo4j,neo4j-ogm,nosql,Neo4j,Spring Data,Spring Data Neo4j,Neo4j Ogm,Nosql,我有一个代码负责在两个节点之间创建新的关系。 首先,它通过属性(pk)获取两个节点,检查这些节点之间是否已经存在这种关系,如果不存在,则创建一个 public void createNeo4jGraphLink(@Nonnull final String childPk, @Nonnull final String parentPk) { final UUID measureId = measureService.startMeasure(MeasureService.MeasureEv

我有一个代码负责在两个节点之间创建新的关系。 首先,它通过属性(pk)获取两个节点,检查这些节点之间是否已经存在这种关系,如果不存在,则创建一个

public void createNeo4jGraphLink(@Nonnull final String childPk, @Nonnull final String parentPk) {
    final UUID measureId = measureService.startMeasure(MeasureService.MeasureEvent.NEO_PERSIST);

    Node child = neoRepository.findOneByPk(childPk);
    Node parent = neoRepository.findOneByPk(parentPk);

    checkIfLinkingAllowed(child, parent);

    if (child.getPartOf() == null || !child.getPartOf().contains(parent)) {
        if (child.getPartOf() == null) {
            child.setPartOf(new HashSet<>());
        }
        child.getPartOf().add(parent);
        neoRepository.save(child);
    }

    measureService.fixMeasure(MeasureService.MeasureEvent.NEO_PERSIST, measureId);
}
public void createNeo4jGraphLink(@Nonnull final String childPk,@Nonnull final String parentPk){
最终UUID measureId=measureService.startMeasure(measureService.MeasureEvent.NEO_);
Node child=neoRepository.findOneByPk(childPk);
节点父节点=neoRepository.findOneByPk(parentPk);
选中允许的链接(孩子、家长);
if(child.getPartOf()==null | |!child.getPartOf().contains(父)){
if(child.getPartOf()==null){
setPartOf(新HashSet());
}
child.getPartOf().add(父级);
neoRepository.save(子项);
}
measureService.fixMeasure(measureService.MeasureEvent.NEO_PERSIST,measureId);
}
我可以看到关系的数量在db中上升,但有一瞬间它急剧下降,以此类推。。什么原因会导致这种行为?我尝试过使用@Transactional注释,尝试过事务的传播和隔离,也尝试过完全不使用事务,但都不起作用。顺便说一句,我使用SpringDataNeo4j存储库。弹簧靴1.4.4.1释放。 子实体和父实体的类型为“节点”,定义如下

@NodeEntity(label = "node")
public class Node {

    private String pk = UUID.randomUUID().toString();

    @JsonIgnore
    private Long id;

    private String name;

    private Set<Node> partOf;

    private String type;

    public Node() {
    }

    @Property(name = "pk")
    public String getPk() {
        return pk;
    }

    public void setPk(String pk) {
        this.pk = pk;
    }

    @GraphId(name = "id")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Property(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Property(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Relationship(type = "PART_OF", direction = Relationship.OUTGOING)
    public Set<Node> getPartOf() {
        return partOf;
    }

    public void setPartOf(Set<Node> partOf) {
        this.partOf = partOf;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Node node = (Node) o;

        if (!pk.equals(node.pk)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return pk.hashCode();
    }
}
@NodeEntity(label=“node”)
公共类节点{
私有字符串pk=UUID.randomUUID().toString();
@杰索尼奥雷
私人长id;
私有字符串名称;
私有集部分;
私有字符串类型;
公共节点(){
}
@属性(name=“pk”)
公共字符串getPk(){
返回主键;
}
公共void setPk(字符串pk){
this.pk=pk;
}
@GraphId(name=“id”)
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
@属性(name=“type”)
公共字符串getType(){
返回类型;
}
公共void集合类型(字符串类型){
this.type=type;
}
@属性(name=“name”)
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
@关系(type=“PART\u OF”,方向=关系。传出)
公共集getPartOf(){
返回部分;
}
公共无效集合部分(集合部分){
this.partOf=partOf;
}
@凌驾
公共布尔等于(对象o){
如果(this==o)返回true;
如果(o==null | | getClass()!=o.getClass())返回false;
Node节点=(Node)o;
如果(!pk.equals(node.pk))返回false;
返回true;
}
@凌驾
公共int hashCode(){
返回pk.hashCode();
}
}
我执行了1800次添加关系,但结果是有62个关系。代码不会抛出任何错误。在处理这1800个请求时,我可以在数据库中看到任意数量的关系(少于1800个),但结果只有62个


谢谢你提供的任何信息

哦,我忘了。上面的代码仅在多线程环境下不能正常工作Define不能工作,还提供了更多信息-您使用的版本、配置、子/父实体等。我添加了一些信息。我可以提供什么配置?您的spring配置,您可以在其中启用存储库、创建会话工厂等。我用SpringBootApplication、EnableTransactionManagement注释了我的应用程序类。在我的配置中,我只为Neo4j数据源声明Bean。也许我需要配置一些其他东西?。