Jpa multi-headed link removal

I have an event table and I want to create groups of them. it's simple and 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 delete a group, but when I want to update a group to remove some links, leaving events still there, I cannot find a way to do this, I am currently deleting the link table operators, but this is not reflected in the parent

+4
source share
1 answer

Just to clarify that ElementForeignKey is an OpenJPA annotation, not a JPA. Unfortunately, there is still no orphanRemoval attribute for the ManyToMany annotation.

+1
source

All Articles