I have a ShoppingCart object that maps to SHOPPING_CART table (primary key SHOPPING_CART_ID) I have a Purchase object that maps to PURCHASE table (primary key PURCHASE_ID) I have a table called SHOPPING_CART_PURCHASES (columns SHOPPING_CART_ID and PURCHASE_ID - both columns make a unique key) which is meant to house the associations between shopping carts and purchases.
My ShoppingCart object has a list of Purchase objects. When I persist ShoppingCart, the Purchase objects that I have added to ShoppingCart purchases are persisted. However no rows are inserted into the association table.
Here is the annotation for ShoppingCart; @ManyToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY) @JoinTable(name="SHOPPING_CART_PURCHASES", joinColumns = { @JoinColumn(name="SHOPPING_CART_ID", nullable=false, updatable=false) }, inverseJoinColumns = { @JoinColumn(name="PURCHASE_ID", nullable=false, updatable=false) }) List<Purchase> purchases = this;
Any ideas how to get the associations to be inserted when I persist the ShoppingCart?
|