Hi,
I've read the chapter 12 of the spring documentation but I still do not understand something about HibernateTemplate.execute and plain Hibernate HQL.
here is my example :
In the 1st way, I know that it will use the good transaction and the good session and also the exceptions will be converted from Hibernate hierarchy to Spring hierarchy.Code://NOTE: uid is a final String //1st way this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { String hql = "DELETE FROM UserSession us WHERE us.uid = ?"; session.createQuery(hql).setString(0, uid).executeUpdate(); return null; } }); //2nd way String hql = "DELETE FROM UserSession us WHERE us.uid = ?"; this.getSession().createQuery(hql).setString(0, uid).executeUpdate();
Is that it ?
in the 2nd way, what is wrong ? Are the transactions correctly used ? Is the exception conversion performed ?
Thanks for any explanations.
Note : if there is some documentation clearer than chapter 12 on the subject, I will also appreciate a hint
Regards,
chirs


Reply With Quote