Hi Tom

In our app we are using pattern where Struts calls a method from what I call
a service layer object.  Then the service layer calls the dao interface.
Then there is an implementation of the dao for Hibernate.  So the call stack
is something like:

Struts Action -> ServiceManager.getSomeObject(Integer id) -> DAO.get(Integer
id) -> return Object

 The service layer are actually Spring beans.  These beans are bound to the
dao's in the Spring appContext.  I am also using Spring to manage the Struts
actions.

I have always wrestled with the DTO question.  I guess I haven't seen the
need for it while using Spring and Hibernate.  I have also created objects
that are specific to the view object (like a set of menu links) that is
being created dynamically and then populated that with the domain objects
values that were needed.   This latter solution is more like a poor mans (in
regards too time) JSF.

With regards to the LazyLoading issues for collections that reference other
domain objects I usually use the Hibernate.initialize(Object) method.  It
will then go through and load the objects in the collection that are
necessary for what domain object you are using.  Then send the object back
to the action to be manipulated as necessary.

Probably not perfect but seems to provide the flexibility we need.  I am
interested to know what others are doing too.

Hope that helps.

Matt Morton

On 11/30/05, Tom Ziemer <[EMAIL PROTECTED]> wrote:
>
> 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]
>
>

Reply via email to