簡體   English   中英

在Neo4j中刪除節點及其所有關系

[英]Deleting a Node and all of its relations in Neo4j

我正在嘗試從Neo4j數據庫中刪除所有Type 我有一個用於Type類的存儲庫typeRepository ,我稱之為typeRepository.deleteAll(); 但是,並非所有內容都被刪除。 僅刪除其節點,使BusinessLogic節點在數據庫中保持活動狀態。 我不確定此時還有什么嘗試,因為方法的名稱暗示它將刪除所有事物,包括自身和與自身相關的事物。 這是我的持久化類的外觀,它擴展了數據庫包含的對象的基本類型:

@NodeEntity
public class BaseType {

    @GraphId
    private Long id;

    @Indexed(unique=true) String uid;
    private String name;

    BaseType() {}

    BaseType(String name) {
        this.name = name;
    }
}

public class Type extends BaseType {

    @RelatedTo(type="businessLogic")
    @Fetch
    private BusinessLogic businessLogic;

    public Type() {super();}

    public Type(String name, BusinessLogic businessLogic) {
        super(name);
        this.businessLogic = businessLogic;
    }
}

@NodeEntity
@XmlAccessorType(XmlAccessType.NONE)
public class BusinessLogic implements Serializable {

    @GraphId
    private Long id;

    private static final long serialVersionUID = -634875134095817304L;

    @XmlElement
    private String create;

    public void setCreate(String create) {
        this.create = create;
    }

    public String getCreate() {
        return create;
    }
}

我只存儲Type實例,並且通過調用

typeRepository.save(new Type(name, businessLogic));

我不認為SDN本身不會進行級聯刪除。 那么,為什么不先通過各自的存儲庫刪除BusinessLogic對象,然后再通過Type對象刪除呢?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM