Hi,
I am thinking of doing the following but am not sure if it is a good idea because of collections.
Currently I have a JSF page which is created in HTTP request scope. When a data object is retrieved from Hibernate and used to set values on this page, only some of the data object's values may be used. Then, when the page is submitted, that subset of values is used to create a new data object with new values for saving to the database. Because it is request scope, some of the property values for the data object will then be null (because they were recreated from the page, which only displayed a subset of values)
Some questions:
a) what can be done to only update those values that have changed, rather than also overwriting unchanged columns with null values
b) am I going to run into trouble with this approach if it is perfectly valid to have null for some of the columns
c) what happens with collections with partial data stored - will it possibly be tricky to use equals/hashcode to decide if an element of the collection needs updating if some of the business key properties of the collection element are null
We could save unused fields as hidden on the Web page, but this could become unmaintainable. The reason for using request scope was to ensure we get fresh data from the database each time the user makes a request (and to avoid logic of deciding when to load blank data etc). But the more I think about it, the more I think the safest option is to keep the data object in HTTP session scope. Is this the usual route? I'd be interested to hear people's opinions/experience.
thanks, Baljeet
|