Hello to everybody!
I've got the following problem and I hope that somebody is able to give me a hint how to solve it:
There are two domain objects Product and Keyword. They are joined as one-2-many (one product can have many keywords):
//slice of Product.hbm.xml: <set name="keywords" lazy="false" inverse="true" fetch="subselect" order-by="name" cascade="all"> <key > <column name="customerId" /> <column name="productId" /> </key> <one-to-many class="....Keyword"/> </set>
Keyword has a composite-id containing four attributes.
The problem is, assuming that I've one product-object with one keyword, when I do some modification on one field of the composite-Key of the keyword and after that I save the product-object, I still get two keywords corresponding to the product-object in the database. One with the "old" composite-key, and one with the modificated one. I can guarantee, that the product Object contains only one keyword before saving.
I know, it's not the finest way to do modifications on key-fields. But in this case it is necessary. How can I tell hibernate to simply update the existing keyword and not to keep the "old" one?
I dont wanna delete every corresponding keyword before saving the product...
Best regards roman
|