These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem on cascading delete.
PostPosted: Fri Jun 12, 2009 2:24 am 
Newbie

Joined: Fri Jun 12, 2009 1:53 am
Posts: 1
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.