Re: Prevent persisting data when validation fails

2009-07-20 Thread Burton Rhodes
I had the same problem while using the opensessioninview pattern. Since this pattern in struts uses an interceptor, in the OSiV interceptor I checked to see if validation had failed in an Action. If so, I "rolled back" the transaction to make sure it didn't persist the data. I eventually removed t

Re: Prevent persisting data when validation fails

2009-07-20 Thread Greg Lindholm
> Thank you very much!! > > During my research, I remember some one solved the issue by creating an > Struts 2 intercepter. He placed the intercepter right after the > validationIntercepter. The job of the intercepter was to check if > getActionErrors or getFieldErrors collections was not empty tha

Re: Prevent persisting data when validation fails

2009-07-20 Thread taltun
> I guess you can use clone, but I always write a copy constructor for > entity > classes so I have more control over handling of references to other > entities. > > -- View this message in context: http://www.nabble.com/Prevent-persisting-data-when-validation-fails-t

Re: Prevent persisting data when validation fails

2009-07-20 Thread Greg Lindholm
> > By the way, how can I let JPA return a deatached object ? > > I make use of GenericDaoJpa.java which is attached to this message. > http://www.nabble.com/file/p24571326/GenericDaoJpa.java GenericDaoJpa.java > > > See http://stackoverflow.com/questions/31446/detach-an-entity-from-jpa-ejb3-persis

Re: Prevent persisting data when validation fails

2009-07-20 Thread taltun
; your problem you have a couple of choices: > > 1) Don't make changes to db objects unless you are sure you want them > saved. This would mean changing your actions to work with copies of the > objects or Detached objects instead of the actually db objects (this is > what

Re: Prevent persisting data when validation fails

2009-07-20 Thread taltun
unless you are sure you want them > saved. This would mean changing your actions to work with copies of the > objects or Detached objects instead of the actually db objects (this is > what > I do). > > 2) Don't commit the transaction if the validation fails. Do a rollback > inste

Re: Prevent persisting data when validation fails

2009-07-20 Thread Greg Lindholm
> I use JPA (hibernate) to persist. > > > > An example of action that use prepare to load a person object from > transactional manager. When the validate fails and it return back to the > input page the request ends and the transaction persists the dirty user > object to database. The dirty user ob

Re: Prevent persisting data when validation fails

2009-07-20 Thread taltun
method to load e.g an user object from a > manager/service. And the data relates to the user object that is about. > > -taltun > -- View this message in context: http://www.nabble.com/Prevent-persisting-data-when-validation-fails-tp24566713p24569948.html Sent from

Re: Prevent persisting data when validation fails

2009-07-20 Thread Jim Kiley
-- > View this message in context: > http://www.nabble.com/Prevent-persisting-data-when-validation-fails-tp24566713p24566713.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To

Prevent persisting data when validation fails

2009-07-20 Thread taltun
e.g an user object from a manager/service. And the data relates to the user object that is about. -taltun -- View this message in context: http://www.nabble.com/Prevent-persisting-data-when-validation-fails-tp24566713p24566713.html Sent from the Struts - User mailing list archive at Nabble.com