-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Existing spring mvc app and session in view
PostPosted: Sun Mar 11, 2007 7:31 am 
Newbie

Joined: Thu Sep 25, 2003 7:21 pm
Posts: 17
I am currently working on introducing a session in view filter into an existing spring mvc application. In this application entity objects are often used as "form backing objects" So when editing some object typically the following happens

1) The object is loaded from the database based on its id.
2) Request parameters are bound to the object by using reflection.
3) Some rudimentary validation is done. If there are errors the form is redisplayed.
4) The object is handed of to some manager that may perform some additional sanity checks (is a user name unique etc).

Only after step 3 are any changes persisted to the database. However when I introduce the session in view filter, changes made to a persistent object will automatically be persisted even when validation fails.

Which does make sense but it is clearly not the desired behavior. So I am wondering how i should deal with this (i would assume) common scenario. I tried googling around for some time but did not find a lot of useful information.

Thinking this through I've come up with the following solutions

1) Use setSessionForm. eg. store the persistent entity in the session when rendering the form and use this (now detached) object in the onsubmit.

Concerns : If the session times out the there will be no detached object in the session on onsubmit and spring will create a new (persistent) object to handle the request.

2) Make a deep copy of the form backing object

Concerns : You would probably not want to do this by hand. I wonder if there are any generic solutions that are aware of lazy loaded relations

3) call session.evict after retrieving the object from the database.

Concerns : where would i put the evict method. Having manager.evict seems wrong.

Are there any other (preferably better) solution i did not list and if not which solution or combination of solutions should i pick and why


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.