2010-07-28 78 views
4

我有一个事件表,我想他们的团体。这是容易容易jpa删除manytomany链接

 
    // 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; 
    } 

时,我想彻底删除该组,但是当我想更新组删除一些链接,使事件还在那里,我不能找到这些注释工作方法来做到这一点,我目前正在做链接表的删除语句,但这并没有反映在父实体

+0

做链接表的删除语句是什么意思?你正在执行原生查询还是你正在调用em.remove(product)? – Mike 2010-07-28 22:39:07

+0

(对不起,我没有看到您的评论) 我这样做删除子行: getEntityManager()。remove(entity); – WendyG 2010-08-19 10:29:50

+0

还没有答案... Dag blammy – SoftwareSavant 2012-08-01 15:28:51

回答

1

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