Ayub Khan schrieb:
Hi,
I have impleted the phaseListener using the idea presented
on http://www.jroller.com/HazemBlog/entry/implementing_hibernate_open_session_per
I am getting "org.hibernate.HibernateException: createQuery is not
valid without active transaction" error message.
Below is the code of phase listeners:
public class RestoreViewPhaseListener implements PhaseListener {
public void afterPhase(PhaseEvent event) {
}
public void beforePhase(PhaseEvent event) {
SessionFactory sessionFactory =
HibernateUtil.getSessionFactory();
sessionFactory.getCurrentSession().beginTransaction();
}
public PhaseId getPhaseId() {
return PhaseId.RESTORE_VIEW;
}
}
Please let me where to open and close session and transaction.
Firstly, as Hazem's blog says, you need two PhaseListeners.
But the blog article looks incomplete anyway. As the comment by wolveman
points out, there probably needs to be a transaction around the render
phase as well as one around the postback phase. Shouldn't be too hard to
implement..
Regards,
Simon