Hi,
the app I am currently working on has got the following setup:
- database (Oracle)
- DOM objects (lazy loading for collections)
- DAOs (Spring managed)
- business layer (Spring managed)
- View1: Struts web application
- View2: rich client via web services
I've got two basic design questions regarding this setup:
a) I am using lazy loading, thus I have to initialize each required collection using Hibernate.initialize(obj.getCollection()) in my business layer. I cannot use the open session in view approach, because of the rich client. How should the business layer reflect my need for a varying population of collections (based on each request by the view)? A single method or multiple methods? Will I have to call initialize() on each object manually, or are there any service methods that could do this for me?
b) I do not want to expose the DOM objects loaded by Hibernate to either struts nor the rich client, because these objects/proxies will throw LazyInitializationExceptions if the view accesses uninitialized properties. IMO, this would be bad design, because the view (and even the business layer) should not know anything about hibernate. Thus, I'd have to use DTOs, which would be bad design as well. Is there another approach, that I am not aware of?
Thanks,
Tom
|