The data the view needs is fetched in the dao. its just that there are several views and each needs a different slice of the data. Nulls aren't a problem as the each view won't try to display fields its not interested in.
Our problem is that before the object gets to the view we create another one based on it that makes it easier and faster for the view to display its results ( by converting data to strings and doing formating etc...) The class that does the conversion is very general, that is, it doesn't know or care what view the data is going to. All it knows is how to convert each business object into an equivalent object that all views can display ( though they will generally only display a part of it). Now for us, testing nulls and is easier than using Hibenate.initialize on each field and also removes hibernate specific stuff from our presentation layer.
I will play a bit with threadlocal. I am still unclear as to how to tell the dao that the view has been rendered and that it can close the session. We are also considering having the dao create a new object based on the proxy that returns a special NULL object for any fields that don't have values set and use null for fields that have not been initialized.
|