Eric D Nielsen
Wed, 30 Apr 2008 07:23:54 -0700
Another possible solution I want to try exploring (but unfortunately its Hibernate specific) is making a custom version of the validator interceptor: Inject the session into the interceptor Call session.readOnly(entity,true) on failed validation If I'm reading things correctly this should a) keep the session alive (versus issuing a rollback), keeping the object attached and allow lazy loadingb) stop any of the dirty data in the object from getting pushed back on implicit
or explicit flushes In fact I might flip set readOnly(entity,true) on entrance to the validator interceptor and then set it to false on success. This should allow the validators of submitted version stored quantities to proceed -- for instance the classic example of Order value can't exceed X, when adding a new LineItem -- the validation might trigger a lazy load of the LineItems, so the entity must be "persistence read-only" before any validation starts to avoid writing dirty values back. This still feels like a hackish solution ( and one that probably can't be distributed/incorporated by/into Struts 2's official jars ), but it looks promising... Eric --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]