Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persistence of updated objects

 
Kumara SharmaS
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

This is the scenario 'm facing, I have different objects that are persisted to the DB.
All these objects are updated by user actions, but not always.

How to know if a particular object is updated by the user or not on the server side? If its not updated theres no need to persist it.
Is having a dirty/update check on the object a solution, on which persistence depends?

Or is there a better way to handle this?

Cheers
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not be sure if data is actually changed by user on UI or not.
If you don't want to update record if there is no change, then you will have to maintain a copy of original object in session scope, compare the changed object passed from UI with original object in session
and then if there is any change , update the record in database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic