-->
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.  [ 6 posts ] 
Author Message
 Post subject: Delete Child gives me UPDATE sql - why
PostPosted: Mon Aug 01, 2005 4:37 pm 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Hi All,
I have Parent, child relationsip and I load only child with following way and issue delete child. I am getting update child SQL - Why

Here is the code

session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();
log = LogFactory.getLog("selectCaseClm()");
Child cc = (Child)session.get(Child.class, childid);

log.info("*** Got Child"+ cc.toString()+ " ***");

session.delete(cc);

session.flush();
tx.commit();
session.close();


update CHILD set parentkey=? where childkey=?

and get error
net.sf.hibernate.util.JDBCExceptionReporter SQL Error: 1407, SQLState: 72000


Any help?

Thanks
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 6:42 pm 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Can you post your mappings?


Top
 Profile  
 
 Post subject: Here is my Mapping
PostPosted: Tue Aug 02, 2005 11:40 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
Parent ---------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="efi.edcs.dto.Fldr" select-before-update="true" table="FLDR" dynamic-update="true">
<id name="id" column="FLDR_NUM" type="efi.edcs.persistence.StringType"
unsaved-value="-1" >
<generator class="assigned" />
</id>
-- Set the coumns

-- Child Tables
<set name="cases" cascade="all" lazy="true" inverse="true">
<key column="FLDR_NUM" />
<one-to-many class="efi.edcs.dto.Case" />
<set name="caseclms" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="FLDR_NUM" />
<one-to-many class="efi.edcs.dto.Caseclm" />
</set>
</class>
</hibernate-mapping>

CHILD ---------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="efi.edcs.dto.Case" select-before-update="true" table="CASE" dynamic-update="true">
<id name="id" column="CASE_NUM" type="efi.edcs.persistence.StringType" unsaved-value="-1" >
<generator class="assigned" />
</id>
-- Set attributes

-- Parent tables
<many-to-one name="fldr" column="FLDR_NUM" class="efi.edcs.dto.Fldr" cascade="all"/>

-- Child Tables
<set name="caseclms" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="CASE_NUM" />
<one-to-many class="efi.edcs.dto.Caseclm" />
</set>
</class>
</hibernate-mapping>



SUB CHILD--------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="efi.edcs.dto.Caseclm" dynamic-update="true" select-before-update="true" table="CASECLM">
<id name="id" column="CASE_CLM_SEQ_NUM" type="string" unsaved-value="-1" >
<generator class="assigned" />
</id>
-- Attributes fot the columns
-- Parent table.
<many-to-one name="edcsCase" column="CASE_NUM" class="efi.edcs.dto.Case" cascade="all" />
<many-to-one name="fldr" column="FLDR_NUM" class="efi.edcs.dto.Fldr" cascade="all" />

-- Child table for this Caseclm table.
<set name="clacthiss" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="CASE_CLM_SEQ_NUM" />
<one-to-many class="efi.edcs.dto.Clacthis" />
</set>

</class>
</hibernate-mapping>
---------------------------------------------------------------------------------------------


I issues Session.delete( Caseclm); it gave update statment for Caseclm

I really appreciate you kind help

Thanks
Ramesh


Top
 Profile  
 
 Post subject: eagle79 any idea ?
PostPosted: Wed Aug 03, 2005 8:14 am 
Beginner
Beginner

Joined: Tue Apr 26, 2005 8:39 am
Posts: 34
eagle79 any idea ?


Top
 Profile  
 
 Post subject: Re: eagle79 any idea ?
PostPosted: Wed Aug 03, 2005 7:32 pm 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
rbarun wrote:
eagle79 any idea ?

I apologize rbarun, I've been so wrapped up with a looming deadline at work, I haven't had a chance to look at this in depth. I briefly looked over it last night, and started to mention the cascades on the many-to-one properties of Caseclm, but I don't think that's the problem. You might try removing them temporarily anyway, in case they're creating some sort of strange looping update.

Of course, anyone else out there's welcome to take a look at this and try to answer it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 12:13 am 
Newbie

Joined: Thu Jun 09, 2005 11:11 pm
Posts: 5
Hibernate executes update because link between parent and child must be removed.

If U remove foreign key constraint from Oracle table U can see second query deleting child. All U need is to change order of queries.

Try inverse = false. This tag determine order of SQL queries. In other words this tag determine side which will be responsible for link between parent and child.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.