2010-07-28 69 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屬性。