I have a many to one association between a SocialEvent class and venue class.
I want that when i delete a venue object then the corresponding socialevent object should be deleted, which contains the reference of this venue object.
If it is possible using cascade attribute, let me know that.
Hibernate mapping of both classes are as follows.
This is the Hibernate mapping of venue class.
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="domain.Implementations.Venue" table="Venue">
<id name="id" type="long" column="ID">
<generator class="native"/>
</id>
<property name="uuid">
<column name="UUID"/>
</property>
<property name="name">
<column name="name"/>
</property>
<property name="description" type="text">
<column name="Description"/>
</property>
<property name="createdDate" column="Created"/>
<many-to-one name="address" column="Address" class="domain.Implementations.Address"/>
<many-to-one name="owner" column="Owner" class="domain.Implementations.Member"/>
<many-to-one name="photo" column="Photo" class="domain.Implementations.Photo"/>
</class>
</hibernate-mapping>
This is the Hibernate mapping of social event class which contains the refrence of venueobject.
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="all">
<class name="domain.Implementations.SocialEvents" table="Social_Event">
<id name="id" type="long" column="ID">
<generator class="native"/>
</id>
<property name="uuid">
<column name="UUID"/>
</property>
<property name="description" type="text">
<column name="Description"/>
</property>
<property name="startDate">
<column name="StartDate"/>
</property>
<property name="endDate">
<column name="EndDate"/>
</property>
<property name="name">
<column name="Name"/>
</property>
<property name="isPublic">
<column name="IsPublic"/>
</property>
<property name="createdDate" column="Created"/>
<many-to-one name="gallery" column="Gallery" class="domain.Implementations.PhotoGallery"/>
<many-to-one name="titlePhoto" column="EventImage" class="domain.Implementations.Photo" />
<many-to-one name="venue" column="Venue" class="domain.Implementations.Venue"/>
<many-to-one name="owner" column="Owner" class="domain.Implementations.Member"/>
</class>
</hibernate-mapping>