Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: hibernate-3.1.3
Name and version of the database you are using: Oarcle 10
I am trying to upgrade my Hibernate from version 2 to 3, and to extent got many of the things to work except this one which is giing me hard time, so thought someone might help me out with this.
I have an User who can have one-to-many Permissions.
I have the User object but it doens't have any relation to the Permissions object in the User.hbm.xml file.
I have the Permssions object which has many-to-one as folows
@hibernate.many-to-one column="USERID" class="bo.User"
outer-join="auto" insert="true" update="false"
So when the User is deleted I am trying to run a query to delete explicitly to remove all the permissions and then the user as follows:
Query q = getSession().createQuery("delete from bo.Permission where user=:usr").setEntity("usr", user);
int n = q.executeUpdate();
getHibernateTemplate().delete(user);
But when trying to execute the same I am getting the error as follows:
14:09:15,296 INFO [STDOUT] deleteUser called
14:09:15,296 WARN [FromElementType] Using non-qualified column reference [user -> ([USERID])]
14:09:15,343 INFO [STDOUT] Hibernate: insert into HT_TPERMISSIONS select user0_.PERMISSIONID as PERMISSIONID from TPERMISSIONS user0_ where USERID=?
14:09:15,375 INFO [STDOUT] Hibernate: delete from TPERMISSIONS where (PERMISSIONID) IN (select PERMISSIONID from HT_TPERMISSIONS)
14:09:15,390 INFO [STDOUT] Hibernate: delete from HT_TPERMISSIONS
14:09:15,406 INFO [STDOUT] number deleted from Permission is:: 1
14:09:15,421 INFO [STDOUT] Hibernate: delete from TUSER where USERID=?
And it doesn't delete from the TPERMISSIONS table as mentioned above.
Also I am not sure why it is trying to write to a separate table and then get from it and delete from there.
Please let me know if anyone came across this situation.