How do I delete orphan entities using hibernate and JPA on a many-to-many relationship?

后端 未结 4 1672
猫巷女王i
猫巷女王i 2020-12-30 22:54

I want to delete orphan entities using hibernate and JPA on a many-to-many relationship but all that I found was this attribute the attribute. org.hibernate.annotations.Casc

4条回答
  •  醉话见心
    2020-12-30 23:21

    From the book "Pro JPA 2":

    Only relationships with single cardinality on the source side can enable orphan removal, which is why the orphanRemoval option is defined on the @OneToOne and @OneToMany relationship annotations, but on neither of the @ManyToOne or @ManyToMany annotations.

    It's a bummer, but there is no JPA automated orphan removal for ManyToMany.

提交回复
热议问题