-->
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: composite-element many-to-one delete
PostPosted: Fri Jan 18, 2008 10:16 am 
Newbie

Joined: Fri Jan 18, 2008 8:49 am
Posts: 1
Location: france
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

hibernate 3.2
hi
when I delete a row on table 'Account' I would like to delete automatically a row on 'UserAccount' too. But Only the record on Account is deleted and one on 'UserAccount' is still there. cascade should work but it doesn't.
please help.
This is my configuration:


<class name="geesto.User" table="USER">
<id name="id" column="USER_ID" unsaved-value="null">
<generator class="increment"/>
</id>



<set name="usersAccounts" table="USER_ACCOUNT" cascade="delete" >
<key column="USER_ID" />
<composite-element class="geesto.UsersAccounts" >
<many-to-one name="accountU" class="geesto.Account" column="ACCOUNT_ID" not-null="true" cascade="delete" />
<property name="permission_id" column="PERMISSION_ID" />
<property name="assosDate" column="UA_ASSOCIATION_DATE" type="date" />
<property name="state" column="UA_STATE" />

</composite-element>
</set>

</class>


Account b = new Account();
b.setId(bilancio_id);
Account bis = b.read();
session.delete(bis)



CREATE TABLE IF NOT EXISTS `USER_ACCOUNT` (
`USER_ID` bigint(20) NOT NULL,
`ACCOUNT_ID` bigint(20) NOT NULL,
`PERMISSION_ID` bigint(20) default NULL,
`UA_ASSOCIATION_DATE` date NOT NULL,
`UA_STATE` tinyint(1) default '1',
PRIMARY KEY (`USER_ID`,`ACCOUNT_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `ACCOUNT` (
`ACCOUNT_ID` bigint(20) NOT NULL auto_increment,
`AC_STATE` tinyint(1) unsigned NOT NULL default '1',
`AC_NAME` varchar(30) NOT NULL default 'bilancio',
`AC_CAPTION` varchar(100) default NULL,
`AC_DATE_CREATE` date NOT NULL,
PRIMARY KEY (`ACCOUNT_ID`),

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;
CREATE TABLE IF NOT EXISTS `USER` (
`USER_ID` bigint(20) NOT NULL auto_increment,

PRIMARY KEY (`USER_ID`),
UNIQUE KEY `UT_LOGIN` (`US_LOGIN`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;




Problems with Session and transaction handling?

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



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.