Spring Data Repository does not delete ManyToOne Entity

前端 未结 6 630
陌清茗
陌清茗 2021-01-30 13:39

I\'m am currently trying to use a Spring Data repository to delete some of my entities. The delete call works without any exceptions/error messages, but the entity is not delete

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 14:15

    cascade=CascadeType.PERSIST is used for updating insert in both side but for delete it will restrict.

    @ManyToOne(cascade=CascadeType.PERSIST, fetch = FetchType.LAZY)
    //  @JoinColumn(name = "qid")
        @JoinColumn(name = "qid", referencedColumnName = "qid", foreignKey = @ForeignKey(name = "qid"), nullable = false)
        // @JsonIgnore
        @JsonBackReference
        private QueueGroup queueGroup;
    

提交回复
热议问题