Hi All,
I am using Hibernate3.2.3. I am facing problem while deleting an object which is having composite key. When I call session.delete(object) method with with wrong set of composite key( it means that composite key is not in the database) I dont get any exception. Unless and untill I dont get exception I wont be able to know whether my deletion was successful or not. If I pass correct composite key, things happen normally and that row is getting deleting. Below is my code.
public boolean deleteUser(AppUserProfile user) throws Exception{
try{
session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
sysLog.info("About to delete a user with User Name: "+user.getUserName());
session.delete(user);
session.flush();
session.getTransaction().commit();
return true; // means delete successfull
}catch (Exception e) {
session.getTransaction().rollback();
sysLog.finer(e.getMessage());
throw e;
}
}
Can anyone tell me y is it happening? When I tried doing samething with single primary key, I got exception, so in this it is working in expected way.
|