Here is a common use scenario of messaging:
A message must have at least one recipient. A message shall be deleted after the last one recipient of the message is removed. Is possible that can be done automatically thorough Hibernate configuration/mapping?
Hibernate version:
3.2
Mapping documents:
Code:
<class name="Message" table="message">
<id name="id">
<generator class="sequence">
<param name="sequence">bm_message_id_seq</param>
</generator>
</id>
<many-to-one name="sender" column="sender_id" class="User"/>
<set name="receivers" table="bm_message_receiver">
<key column="message_id"/>
<many-to-many column="receiver_id" class="User"/>
</set>
<property name="tDate" column="tdate" type="calendar" update="false" not-null="true"/>
<property name="content" type="string" column="content"/>
</class>