Home jpa deleting manytomany links
Reply: 0

jpa deleting manytomany links

user980 Published in March 20, 2018, 5:34 am

I have a table of events and i want to make groups of them. that is the easy easy

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

These annotations work when i want to completely remove the group but when i want to update the group to remove some of the links, leaving the events still there, i can't find a way to do this, i am currently doing delete statements of the link table but this doesn't get reflected in the parent entity

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301862 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO