I haven't tried this, but perhaps changing the order the interceptors are specified is a potential way out.
--- [EMAIL PROTECTED] wrote: > True. The action's "execute" method is not being > called. However, in the > ModelDriven pattern, the invalid (in my case Null) > request parameters are > set on the Model during request processing. This is > opposed to a > non-ModelDriven action where the parameters would be > set on Action > properties. > > Since my Model is acquired from the Hibernate > session (during the > "prepare()" Action method), it is a transactional > persistent instance. > Note this from the hibernate documentation: > > "Transactional persistent instances (ie. objects > loaded, saved, created or > queried by the Session) may be manipulated by the > application and any > changes to persistent state will be persisted when > the Session is flushed > (discussed later in this chapter). There is no need > to call a particular > method (like update(), which has a different > purpose) to make your > modifications persistent." > (http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-modifying) > > So when the OpenEntityManagerInView filter closes > the EntityManager at the > end of request processing (even when validation > fails), Hibernate attempts > to write the invalid model object to the database. > > best, > > Jon French > Programmer > ASRC Management Services > ECOS Development Team > [EMAIL PROTECTED] > 970-226-9290 > > Fort Collins Science Center > US Geological Survey > 2150 Centre Ave, Building C > Fort Collins, CO 80526-8116 > > > > "Musachy Barroso" <[EMAIL PROTECTED]> > 10/01/2007 02:42 PM > Please respond to > "Struts Users Mailing List" <user@struts.apache.org> > > > To > "Struts Users Mailing List" <user@struts.apache.org> > cc > > Subject > Re: ModelDriven CRUD validation failure still causes > JPA update > > > > > > > If there is a validation error the code on your > action shouldn't be > executed at all, so you wouldn't have this problem. > Are you applying > the "defaultWorkflow" interceptor to your action? > > regards > musachy > > On 10/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> > wrote: > > I have a ModelDriven action which controls CRUD > operations on JPA > managed > > Entity E. E has a property called ?name? which > maps to a database column > > with a NOT NULL constraint. I have added a > RequiredStringValidator > > annotation to my Action to validate that the > ?model.name? property is > > non-null. The validation works perfectly. > > However, during Struts Interceptor processing of a > user entered empty > > string for the ?model.name? ServletRequest > parameter, entity instance E > > has its getName() property set to a null value. > Hibernate (my JPA > > implementation provider) detects this property > state change when the > > Hibernate session is flushed at the closing of the > JPA EntityManager by > > the configured OpenEntityManagerInView > ServletFilter. This results in an > > attempt by Hibernate to update the ?name? database > column to null and > > results in a SqlException. > > So the problem is that even with appropriate > validation on a ModelDriven > > action, my Entity moves to an invalid state which > Hibernate then tries > to > > persist to the database at the closing of the > session. > > Based on what I gleaned from this WebWorkx post: > > > http://forums.opensymphony.com/thread.jspa?messageID=5315ᓃ > > (which seems to be the exact same problem except > with the > > OpenSessionInView filter instead of my > OpenEntityManagerInView filter) > > And this spring post: > > > http://forum.springframework.org/showthread.php?t=35740 > > ? I think that what I need to do is set > Hibernate?s flush mode to > NEVER. > > What this means to me is that Hibernate will only > flush when I execute a > > EntityManager.flush() command and that > OpenEntityManagerInView?s closing > > of the EntityManager won?t automatically result in > a Hibernate session > > flush and thus Entity E?s invalid state will not > be persisted. This is > in > > line with what I understand to be the default > behavior of Spring?s > > OpenSessionInView filter. Unfortunately, I have > not yet been able to set > > Hibernate's flush mode (nor am I certain that this > will solve my issue). > > Can anyone shed some light on this problem? > > Thanks in advance! > > > > Jon French > > Programmer > > ASRC Management Services > > ECOS Development Team > > [EMAIL PROTECTED] > > 970-226-9290 > > > > Fort Collins Science Center > > US Geological Survey > > 2150 Centre Ave, Building C > > Fort Collins, CO 80526-8116 > > > -- > "Hey you! Would you help me to carry the stone?" > Pink Floyd > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]