jordan wrote:
Hi,
I have an method that tries to update a hibernate mapped object. The object that I am trying to update is a Product object which has a many-to-many relationship with the supplier objects.
1. public ProductDataObject updateProduct(ASObject asProduct) {
2. Product product = (Product) new ASTranslator().fromActionScript(asProduct);
3. return (ProductDataObject) new ProductDAO().makePersistent(product).getDataObject();
4. }
On line 2. the product object is fully populated except for the "supplier" field which is a Set of Supplier objects. The "supplier" field is null at this stage. When I try to save this Product object on line 3 there is a query executed that deletes the existing supplier relationship. Other than trying to select the supplier collection from the database is there another way that I can stop this relationship deletion from happening?
Is there a way to tell hibernate to only delete collections when I specify it? I essentially only want hibernate to update relationships when the code tells it to. (or the mapping files tell it to).
Any pointers would be appreciated.
Thanks
Jordan
[b]Hibernate version:3.05
[b]Name and version of the database you are using:MySQL
[b]The generated SQL (show_sql=true):
Can you include your mapping files.