anthony wrote:
Quote:
add to these child objects to the parent object
this operation shouldn't be in the ui layer...
anyway, if you want to avoid the exception just fetch the collection when querying
This is only part of the solution. You may hit the same problem while accessing your lazy loaded properties in your ui layer (which is valid). In this situation, forcing the 2nd tier to initialize all properties that will be used by the ui layer is not something that should be part of the 2nd tier (or maybe in a kind of adapter layer in between).
Having tried different solutions, it seems to me the best approach is to have to Hibernate session handling made by a servlet filter. This way, you are sure your Session is opened until the request is completed - even during JSP rendering if any.