Hi to all,
i have three tables:
Event -
Comment -
PlaceBoth events and places can have comments, so that the Event entity has a bidirectional <one-to-many> association with Comment, and Place has a bidirectional <one-to-many> association with Comment too.
The comment can be associated with an event or a place,
but not with both.
The Comment has therefore two,
not optional joins (because i don't know whether it will be associated with event or place):
Code:
<join table="EventComment" inverse="true" optional="true">
<key column="commentId" />
<many-to-one name="event" column="eventId" not-null="true" class="Event" />
</join>
<join table="PlaceComment" inverse="true" optional="true">
<key column="commentId" />
<many-to-one name="place" column="placeId" not-null="true" class="Place" />
</join>
What i actually wand to do is: when i delete the child entity Comment, i want the parent entity (that could be an Event or a Place) to update its
comments collection automatically. I wonder if there is such a cascade propery to achieve this.
What i'd like to avoid is to check for the parent entity class, and then explicitly call [event or place].getComments().remove(comment)
Thanks in advance