When a workflow automatically opens and closes a transaction, so that
it can cover multiple operations, and something goes wrong during the
course of the transaction, then we need to rollback the transaction.

In the case of validation, sometimes changes are made to a property
which causes it to become (for example) NULL, and later in the
lifecycle the validator sees that the property is NULL, and raises the
validation error. But, by then, the property is changed, and the
Hibernate Session (or JPA EntityManager) will commit the change when
the transaction is automatically closed.

Since the Hibernate Validator and JSR 299 push validation back to the
model (where it arguably belongs), making it easy to signal for a
rollback in a multioperation transaction becomes more important.

I'm still ramping up on the JPA myself, but in some early tests I
found that not committing the transaction has the same affect of a
rollback.

-- HTH, Ted
 * <http://www.StrutsMentor.com/>

On Dec 17, 2007 4:04 PM, Alberto A. Flores <[EMAIL PROTECTED]> wrote:
> Is anyone using openSessionInView with Struts 2 (Hibernate, Spring)?
>
> I've found a problem where a domain model is still persisted (even
> though I'm not saving it) after validation finishes (showing validation
> errors). My prepare method makes a query (using a
> HibernateTemplate().get() method) but that's all? Has anyone seen
> something similar?
>
> I'm very sorry if this is not a Struts2 question, but thought of asking
> since Struts2 is using Filters now and was wondering if anyone has seen
> any similar behavior.
>
> Thanks,
>
> --
>
> Alberto A. Flores
> http://www.linkedin.com/in/aflores

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to