-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with the the updation of an object.
PostPosted: Mon Aug 08, 2005 6:11 am 
Newbie

Joined: Tue Sep 07, 2004 10:16 am
Posts: 1
I have an object for storing "personal details (person)", during the user updation what I’m doing is using hql I’ll load the existing "person”, and then according to the user input the object will be modified. Before the object with new values is persisted, it is validated. If there are some errors I want the old object back (Peron with original values). For this purpose, if the is any error, I’ll load the "person" again.

At this point I’m facing a problem, the newly loaded object
is reflecting the changes made by the user ( the newly loaded "person" is supposed to be the one with values before updating, since the updated person is not persisted yet.).

Due to this, the user may get a feeling that the "person" is updated with wrong values, even if this is not the case. For my project I’m using Struts with Hibernate.
Please suggest a solution.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 6:44 am 
Regular
Regular

Joined: Wed May 05, 2004 8:01 am
Posts: 53
create a special class that will hold person data which you will validate (you could name PersonFormData) and then:

1. load Person object
2. transfer data to PersontFormData
3. edit PersonFormData
4. validate
5. if valid transform data from PersonFormData into Person object
6. persist Person

this way you will not have your persistent data model in inconsistent state.

You may want to look at cocoon forms (http://cocoon.apache.org/2.1/). There is a block called CForms which has it's own form model (no need to create PersonFormData class).


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

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.