-->
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: cascad delete issues
PostPosted: Wed Oct 04, 2006 9:21 pm 
Beginner
Beginner

Joined: Thu Oct 06, 2005 8:14 pm
Posts: 23
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

I am trying to do some cascade deletes
this is how my schema looks



I have a persistable object which in turn has a composite-element called value object
and that in turn refers to an external object
which in turn has some value objects within it
Now I want to delete the external object when I delete the compositelement
this doesn't happen
Someone on this forum suggested I change composite-element to entity that did not solve the issue as well



Posting my mappings and sql

<?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=".....">

<class name="ExternalObject" table="ExternalObject" lazy="false">

<id name="id">
<generator class="native" />
</id>

<property name="created" not-null="true" column="`created`" />
<property name="lastUpdated" not-null="true"
column="`lastUpdated`" />
<bag name="valObject1" lazy="true" table="ValObject1" cascade="all">
<key column="id" />
<composite-element class="ValObject1">
<property name="name" column="name" />
<property name="first" column="first" />
<property name="second">
<column name="second" />
</property>

</composite-element>

</bag>

<bag name="valObject2" lazy="true" table="ValObject2" cascade="all">
<key column="id" />
<composite-element class="ValObject2">
<property name="third" column="third" />
<property name="fourth" column="fourth" />
<property name="fifth">
<column name="fifth" />
</property>

</composite-element>

</bag>
</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="......">

<class name="PersistableObject" lazy="true"
table="PersistableObject">

<id name="id">
<generator class="native" />
</id>

<property name="created" not-null="true" column="`created`" />
<property name="lastUpdated" not-null="true"
column="`lastUpdated`" />

<bag name="valueObject" lazy="true" table="ValueObject"
cascade="all">
<key column="id" />
<composite-element class="ValueObject">
<property name="first">
<column name="First" />
</property>
<property name="second">
<column name="Second" />
</property>

<!-- <one-to-one name="obj" cascade=""/> -->
<many-to-one name="obj" column="Obj_Id"
unique="true" class="com.tramada.persistence.hibernate.ExternalObject"
cascade="all" />

</composite-element>
</bag>

</class>

</hibernate-mapping>

( "CREATE TABLE `PersistableObject` ("
"`lastUpdated` datetime NOT NULL default '1970-01-01 00:00:00',"
"`created` datetime NOT NULL default '1970-01-01 00:00:00',"
"`id` int(10) unsigned NOT NULL auto_increment,"
"PRIMARY KEY (`id`)"
") ENGINE=" DB_TYPE " DEFAULT CHARSET=latin1;" );

( "CREATE TABLE `ExternalObject` ("
"`lastUpdated` datetime NOT NULL default '1970-01-01 00:00:00',"
"`created` datetime NOT NULL default '1970-01-01 00:00:00',"
"`id` int(10) unsigned NOT NULL auto_increment,"
"PRIMARY KEY (`id`)"
") ENGINE=" DB_TYPE " DEFAULT CHARSET=latin1;" );

( "CREATE TABLE `ValueObject` ("
"first varchar(200),"
"second varchar(200),"
"id int(10) ,"
"Obj_Id int(10) references ExternalObject(id)"
") ENGINE=" DB_TYPE " DEFAULT CHARSET=latin1;" );
( "CREATE TABLE `ValObject1` ("
"first varchar(200),"
"second varchar(200),"
" name varchar(200),"
"id int(10) references ExternalObject(id)"
") ENGINE=" DB_TYPE " DEFAULT CHARSET=latin1;" );
( "CREATE TABLE `ValObject2` ("
"third varchar(200),"
"fourth varchar(200),"
" fifth varchar(200),"
"id int(10) references ExternalObject(id)"
") ENGINE=" DB_TYPE " DEFAULT CHARSET=latin1;" );

Some one please help me


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 05, 2006 7:34 pm 
Beginner
Beginner

Joined: Thu Oct 06, 2005 8:14 pm
Posts: 23
Any body......
All i want to do is that when I set the value object to null it delets the external object tree as well

Can some one help me on this....


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.