I am trying to create a wizard-like registration where I have multiple pages with each one a form and a "save and continue" button. I want to save the data of each form in a hibernate session and save it on the DB only at the end of the registration when the user confirms. I am not an Hibernate expert but I understood that I need to create a "long session". How do I do that? Do I do that by leaving the transaction open? How do I retrieve the "dirty" entity from one request to the other ? Say we have an GWTP action handler that does something like this
//page1 action
public myAction1Result execute(myAction1Action action,ExecutionContext context) throws ActionException {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.getTransaction().begin();
User entityUser = new User();
entityUser.setName(action.getName());
session.save(entityUser);
return new myAction1Result();
}
Until the transaction will be open the userEntity won't be saved in the DB and will be transient. How I can retrieve it in another actionHandler?