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