Chase on 01/05/08 06:04, wrote:
Adam Hardy wrote:
the problem was spurious JPA updates - which can be avoided by putting
an interceptor in between the Validation and the Workflow
interceptors: all it should do is call EntityManager.clear().
if (validationAwareAction.hasErrors()) getEntityManager().clear();
Using the JPA extended persistence context (not EJB), the clear() will
eliminate any changes to the model before JPA comes to flush to the
db. I assume it would work in an EJB container too.
Does that fit your situation, Eric?
Then wouldn't the following work?
public void validate() {
//any actual validation code here
if(hasErrors()) {
//clear EntityManager or fail transaction
}
}
Yes it would work, although I haven't tried it yet.
Actually I think you have to do it this way.
My idea of a 'ValidationFailure' interceptor placed before the workflow
interceptor would not work when Action.validate() fails the validation.
NB it's counter-intuitive for WorkflowInterceptor to call Action.validate() - I
thought ValidationInterceptor did that. What was the rationale behind that design?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]