Hi, can anyone help me with this problem?
I have two entities (products and attributes of the product) mapped with annotations this way:
ProductVO --> 1-N --> AttribVO
ProductVO ---------------- @OneToMany(fetch=FetchType.EAGER,mappedBy="product",cascade=CascadeType.ALL) @OrderBy("order ASC") @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN) private List<AttribVO> attribs;
AttribVO ----------------
@ManyToOne @JoinColumn(name="LPRODUCTID") private ProductVO product;
I have two attributes "a" and "b" for the product. If I set a new list of attributes (only with a "c" attribute) in product and update it, attributes "a" and "b" are not deleted and attrib "c" is added to the list of attributes:
Product p = findProduct(); //I have 2 attributes here p.getAttribs(); List<AttribVO> aList = new ArrayList<AttribVO>(); aList.add(new AttribVO("c")); //Only attribute c here p.setAttribs(aList); updateProduct(p);
Can I update the product attributes list and delete products "a" and "b" with this mapping or i can't make this and i have to do a "pre-delete" of the attributes??
Thanks for your help.
Best regards.
|