-->
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: Joined-subclass - parent doesn't get deleted!!!!
PostPosted: Wed Mar 09, 2005 1:05 pm 
Newbie

Joined: Fri Feb 11, 2005 10:23 am
Posts: 4
Location: Developer
So I've got a Party model going on where Customer for instance is a joined subclass of Party. When I delete a customer like so:

Code:
    /**
     * @see com.glasermills.dao.CustomerDAO#removeCustomer(java.lang.String)
     */
    public void removeCustomer(Integer id) {
        Customer customer = getCustomer(id);
        getHibernateTemplate().delete(customer);
    }


The row from the Customer table gets deleted (i.e. the joined-subclass table) but not from the Party table! What's up with that I wonder? The getHibernateTemplate() call is from Spring's HibernateDAOSupport class.

Thanks all. Mapping docs (XDoclet generated) and other info below.

Hibernate version:
2
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="com.glasermills.model.party.Party"
        table="Party"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="id"
            column="PartyId"
            type="java.lang.Integer"
            unsaved-value="null"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Party.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="name"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="Name"
            length="64"
            not-null="true"
        />

        <set
            name="locations"
            table="PartyLocation"
            lazy="false"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
        >

              <key
                  column="PartyId"
              >
              </key>

              <many-to-many
                  class="com.glasermills.model.party.Location"
                  column="LocationId"
                  outer-join="auto"
               />

        </set>

        <set
            name="contacts"
            table="PartyContact"
            lazy="false"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
        >

              <key
                  column="PartyId"
              >
              </key>

              <many-to-many
                  class="com.glasermills.model.party.Contact"
                  column="ContactId"
                  outer-join="auto"
               />

        </set>

        <property
            name="dateCreated"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="DateCreated"
            not-null="true"
        />

        <property
            name="dateModified"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="DateModified"
            not-null="true"
        />

        <many-to-one
            name="primaryLocation"
            class="com.glasermills.model.party.Location"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="primaryLocationId"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Party.xml
            containing the additional properties and place it in your merge dir.
        -->

        <joined-subclass
            name="com.glasermills.model.weaver.Weaver"
            table="Weaver"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="WeaverId"
        />

        </joined-subclass>
        <joined-subclass
            name="com.glasermills.model.customer.Customer"
            table="Customer"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="CustomerId"
        />

        <set
            name="customerShippingAccounts"
            lazy="false"
            inverse="true"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

              <key
                  column="CustomerId"
              >
              </key>

              <one-to-many
                  class="com.glasermills.model.customer.CustomerShippingAccount"
              />

        </set>

        <many-to-one
            name="priceSchedule"
            class="com.glasermills.model.customer.PriceSchedule"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="PriceScheduleId"
        />

        <set
            name="customerCreditCards"
            lazy="false"
            inverse="true"
            cascade="all-delete-orphan"
            sort="unsorted"
        >

              <key
                  column="CustomerId"
              >
              </key>

              <one-to-many
                  class="com.glasermills.model.customer.CustomerCreditCard"
              />

        </set>

        </joined-subclass>

    </class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Using Spring HibernateTemplate

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.