Hi there,
I write a program which contains "user" and "staff" class. And the "staff" class is subclass of "user".
public class User extends BaseModel { protected boolean gender;
protected String name;
/* getter & setter */ }
public class Staff extends User { /* Link to User class ("many-to-one" relationship) */ private User supervisor; private double salary;
/* getter & setter */ }
And in hbm file, I use "join-subclass" to configure them.
<class name="User" table="USER"> <id name="id" column="ID" type="string" length="32"> <generator class="uuid"/> </id> <property name="gender" column="GENDER" not-null="true" /> <property name="name" column="NAME" length="100" not-null="true" />
<joined-subclass name="com.crazysoft.db.domainobj.user.staff.Staff" table="STAFF"> <key column="ID"/> <property name="salary" column="SALARY" not-null="true" /> <many-to-one name="supervisor" column="SUPERVISOR" class="User" not-null="true" /> </joined-subclass> </class>
And the problem is every time, I delete the staff object, hibernate always deletes the related user object as well.
So, is there a way to only remove staff object and keep the related user object?
Thanks for help!
|