Back Forum Reply New

saveOrUpdate betwen pages in a WizardController

Hello everybody!

I'm in trouble using Wizards and Hibernate. I'm building a web app where researches submit their works, passing through 7 steps.

I've created a big class called Project, where lots of associations exists. I'm using the OpenSessionInViewInterceptor with FLUSH_AUTO. On each step, some properties/associatons are populated by the form (i'm binding them with spring TLD).

When user advances each step, if everything is validated correctly, a business method marked as PROPAGATION_REQUIRED (not readOnly) do the saveOrUpdate(project) routine.

In the first step, when the object is new, the save method is called correctly.  When the method exits the call stack, the register is persisted in the database (I'm using IBM DB2 UDB v8).

Continuing, after user submits step 2, the update method should be triggered, right? But when the method ends, the data isn't updated in the DB! Instead, it is only updated when the 3rd step form apears in the browser, but it's too late! The 3rd step creates some empty objects (associations in cascade-all style), which properties will be fullfiled by the user, that throws Foreign keys exceptions, because it was persisted before user submits the 3rd step form. In other words, the referenceData method called in step 3 is executed BEFORE the Session flushes the saveOrUpdate called after validatePage(step2).

I've already tried changing flush mode to COMMIT, and also adding getHibernateTemplate().flush() after the saveOrUpdate(), without success.

I'm using Spring 1.2.6 with the bundled hibernate3.jar

Thanks!
¥
Back Forum Reply New