I have a pretty simple JPA @ManyToMany connection installed in my application. A Product is part of one or more OrderSystem s. Each OrderSystem can have many Product s. This is a typical many-to-many relationship.
The problem I'm fighting is this: if I use orderSystems.remove() to remove the link from Product to OrderSystem , the record will be deleted (during this session). However, the record is not deleted from the flash cross-reference table, and when I reload Product , it has the previous set of OrderSystem s.
I have the following code:
@Entity @Table(name = "p_product_versions") @Validation public class Product { private List<OrderSystem> orderSystems; @ManyToMany @JoinTable(name = "p_order_systems_has_product_versions", joinColumns = @JoinColumn(name = "p_product_versions_prod_version_id"), inverseJoinColumns = @JoinColumn(name = "p_order_systems_system_id")) public List<OrderSystem> getOrderSystems() { return orderSystems; } } @Entity @Table(name = "p_order_systems") @Validation public class OrderSystem { private List<Product> products; @ManyToMany (mappedBy = "orderSystems") public List<Product> getProducts() { return products; } }
Can someone point me to what I am missing here?
source share