-->
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.  [ 2 posts ] 
Author Message
 Post subject: Difficulties with delete-orphan
PostPosted: Thu Jun 02, 2005 3:03 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
In a one-to-many relationship, i am trying to use all-delete-orphan cascade option.

I have no problems with insert or update in master and child table.

But when i remove some records from the collection and do a saveOrUpdate, the removed records from the collection are not
getting deleted from the database.

Delete sql is never getting triggered on the child table.

Any thoughts and suggestions are highly appreciated.

Hibernate version:
3.0

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="schema">

<class name="SlpgRoom" table="PROP_PRDT_SLPG_RM">

<id name="propertyProductId">
<column name="PROP_PRDT_ID" length="15" not-null="true"/>
</id>

<property name="defaultBaseCount">
<column name="SLPG_RM_DFLT_INV_BASE_QTY" length="9" not-null="false" />
</property>


<set name ="connectingRoomTypeProducts" cascade="all-delete-orphan" inverse="true" outer-join="false" lazy="false">
<key column ="PROP_PRDT_ID"/>
<one-to-many class="ConnectingRoom"/>
</set>

</class>

</hibernate-mapping>

==============================

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="schema">

<class name="ConnectingRoom" table="PROP_PRDT_SLPG_RM_CONNECT">

<composite-id>
<key-property name="propertyProductId" column="PROP_PRDT_ID"/>
<key-property name="connectPropertyProductId" column="CONNECT_PROP_PRDT_ID"/>
</composite-id>

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
SlpgRoom slpg = new SlpgRoom();
ConnectingRoom connectRoom = new ConnectingRoom();
ConnectingRoom connectRoom1 = new ConnectingRoom();

connectRoom.setConnectPropertyProductId(new Integer("1000"));
connectRoom.setPropertyProductId(new Integer("580"));

connectRoom1.setConnectPropertyProductId(new Integer("1000"));
connectRoom1.setPropertyProductId(new Integer("582"));

Set connectingRooms = new HashSet();
connectingRooms.add(connectRoom);
//connectingRooms.add(connectRoom1);

slpg.setConnectingRoomTypeProducts(connectingRooms);
slpg.setDefaultBaseCount(new Integer("11"));
slpg.setPropertyProductId(new Integer("1000"));

tx = session.getTransaction....
session.save(slpg);
tx.commit()......

Full stack trace of any exception that occurs:


Name and version of the database you are using:
Oracle 10G
The generated SQL (show_sql=true):

Hibernate: select slpgroom_.PROP_PRDT_ID, slpgroom_.SLPG_RM_DFLT_INV_BASE_QTY as SLPG2_1_ from PROP_PRDT_SLPG_RM slpgroom_ where slpgroom_.PROP_PRDT_ID=?

Hibernate: select connecting_.PROP_PRDT_ID, connecting_.CONNECT_PROP_PRDT_ID from PROP_PRDT_SLPG_RM_CONNECT connecting_ where connecting_.PROP_PRDT_ID=? and connecting_.CONNECT_PROP_PRDT_ID=?

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 7:11 am 
Newbie

Joined: Mon Nov 14, 2005 7:07 am
Posts: 9
I have the exact same problem, any solutions anyone?


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

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.