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