Jan-Olav Eide
Jan-Olav Eide

Reputation: 403

Struts2 access to "original" model object

I have an application where I require to have some auditing of changes. In practice this means that I need to know what the original Model object was when I update it. In my code I (obviously) have access to a Model object with the modified values, but not the original (that was used for rendering the edit page in the first place . What is the recommended practice for this, put the originasl model object into session storage before rendering it ? Anything else ?

Upvotes: 1

Views: 99

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

You either need to re-retrieve the object (if it's persisted), or keep it around in a conversation (e.g., the session, but only for the required duration).

This may be better-handled by the persistence layer, depending on what you're using. A reasonable caching solution means a very low performance impact of a re-query.

Upvotes: 3

Related Questions