Hi
I'm having a problem trying to update a parent-child relationship using a composit-id object, the old records are not removed from the table and they are left without parent's reference, though there is a cascade="all-delete-orphan" on the association.
This is the situation, the parent Table is called Offer and the child RateCode, I save a previous existing Offer adding 2 new RateCodes. The new RateCodes are added all right but the old ones are not removed from the RateCode table, instead the FKOFFER value is set to null. There is no exception, but I'd like to remove those unreferenced records when saving. Please help!
Million thanks in advance!
j a p
Hibernate version:
3.1.2
Mapping documents:
Code:
<class name="Ffpoffer" table="FFPOFFER" where="(deleted is null)">
...........
<set name="ffpofferratecodeSet" cascade="all-delete-orphan">
<key column="FKOFFER"/>
<one-to-many class="Ffpofferratecode"/>
</set>
</class>
<class name="Ffpofferratecode" table="FFPOFFERRATECODE">
<composite-id name="id" class="OfferRateCodeKey">
<key-many-to-one name="rateCode" column="FKRATECODE" class="com.domain.bmdev.RateCode" />
<key-many-to-one name="ffpoffer" column="FKOFFER" class="Ffpoffer" />
</composite-id>
</class>
public class Ffpofferratecode
implements Serializable
{
private OfferRateCodeKey id;
public Ffpofferratecode()
{}
public OfferRateCodeKey getId() {
return id;
}
public void setId(OfferRateCodeKey id) {
this.id = id;
}
}
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: