首页 文章

jpa删除manytomany链接

提问于
浏览
4

我有一个事件表,我想组成他们 . 这很容易

// this cascade group still removes the join table but not the products table
@ManyToMany(targetEntity=Product.class,fetch = FetchType.EAGER, cascade = 
   {CascadeType.PERSIST, CascadeType.REFRESH,CascadeType.MERGE})
@JoinTable(name = "lcw_group_product", 
    joinColumns = { @JoinColumn(name = "group_id", referencedColumnName="id") }, 
    inverseJoinColumns = { @JoinColumn(name = "product_id", referencedColumnName="id") })
@ElementForeignKey(updateAction = ForeignKeyAction.CASCADE)
    public Set getProducts() {
        return products;
    }

当我想要完全删除组时,这些注释工作,但当我想更新组删除一些链接,让事件仍然存在,我找不到办法做到这一点,我目前正在做删除语句链接表,但这不会反映在父实体中

1 回答

  • 1

    只是为了澄清ElementForeignKey是一个OpenJPA注释,而不是JPA注释 . 不幸的是,到目前为止,ManyToMany注释没有orphanRemoval属性 .

相关问题