Hello, I agree with mostly of what you said... And add a little thing... If your domain objects & DTO implements a common interface, if your domain object changes you'd need to change its interface, so you will be forced To change also the DTO... I don't think you can get away with it
Unless what you are doing is to just get objects from hibernate layer and put them straight into the page where you just use struts tags to retrieve Properties..... then I guess I see your point..... In my case I chooseed to have a common interface for DTO & domain, and I am just using BeanUtils to copy Properties between the two (so I save the hardcoded method copy) Well, I haven't dealt with LazyInitializationException, so I don't know much About it... but will it be a solution to copy what hibernate has returned To a new Collection, so that you could handle the LazyInitializationException in your hibernate layer? Any reasons of why you can't do that? Regards marco -----Original Message----- From: Tom Ziemer [mailto:[EMAIL PROTECTED] Sent: 30 November 2005 14:51 To: Struts Users Mailing List Subject: Re: slightly [OT] Hibernate and domain objects in web apps Hi, well, I can use DTO but AFAIK, it would be a bad design decision to use them, because it would basically mean that I have to copy all my DOM-objects. So if there changes in the DOM, the DTOs would have to be manually updated. Apart from that, it would mean: Hibernate -> DAO -> Business layer -> covertDOMToDTO -> DTO -> View and then in case of an update: View -> DTO -> Business layer -> convertDTOtoDOM -> DAO -> update() -> IMO, lots of trouble, an additional error risk and poorer performance. That's why I thought, it would be prudent to avoid using DTOs. Tom Marco Mistroni wrote: > Hello, > Any reason of why you can't use DTOs? > Your domain objects and dto could implement the same interface.. > > > > HTH > marco > > -----Original Message----- > From: Tom Ziemer [mailto:[EMAIL PROTECTED] > Sent: 30 November 2005 14:26 > To: Struts Users Mailing List > Subject: slightly [OT] Hibernate and domain objects in web apps > > Hi, > > I have got a little problem with Hibernate - well actually it is only > partially related to it: > > My app uses Spring + Hibernate (lazy loading), but should I return the > value beans (dom) from Hibernate to my Struts actions? If I do this, I'd > have to deal with LazyInitializationExceptions for collections that have > been lazy-loaded. In my opinion, this would be a horrible design because > the view would have to know about the data access tier. On the other > hand, I've read, that "DTOs are evil" - but how can I solve this problem > without DTOs? > > I am sure, lots of you are using > Hibernate/{YOUR_LIST_OF_OTHER_GREAT_FRAMEWORKS_HERE}/Struts and I'd be > grateful for any help. > > Thanks, > Tom > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]