-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate + Web Architecture + DAOs
PostPosted: Mon Jun 07, 2004 6:04 pm 
Newbie

Joined: Thu Apr 15, 2004 10:17 am
Posts: 14
Location: Manhattan
Hibernate Version: 2.1.4
Database: SQL Server
Use of multiple datasources
Use of Spring Framework

Hi there,

I've spent the good portion of the day reading through posts on the Hibernate forum regarding different strategies for handling lazy loading in the context of a web application architecture. We've been using Hibernate for about 3 months now and our architecture is based on Struts with our Struts actions talking to DAOs which then front Hibernate. After reading the article titled "Session and Transaction Scope" (http://www.hibernate.org/168.html) it appears that are model is based on the session-per-operation antipattern where our application hits the DAO multiple times during a web request and each fetch method in the DAO opens and closes the session. I see that the documentation in the "Session and Transaction Scope" article says this is a bad approach but it doesn't say why. Is there too much overhead in opening and closing a session multiple times within a request?

Second, which approach is best given our architecture of Struts -> DAOs -> Hibernate? I also read the article titled "Thread Local Session" (http://www.hibernate.org/42.html) in which an approach to maintaing a Hibernate session is detailed. What I'm fuzzy about is whether or not we want to use the Spring framework to implement the Hibernate session maintenance and whether or not the Spring framework will handle multiple session factories. Currently, we have the Spring framework configured to handle multiple session factories for each of the 5 databases with which we need to communicate.

Lastly, will the Thread Local Session approach solve the lazy loading problems we are seeing in our application by keeping the session open? I realize there are several solutions for solving lazying loading, including the servlet filter fronting all requests and reattaching the parent object to a new session. With respect to the latter approach, where would I perform the reattachment of the parent object given an architecture of Struts Actions -> DAOs -> Hibernate? I know there has to be a few other people reattaching objects to new sessions inside an architecture that supports DAOs so I'm curious what everyone else is doing. This post alludes to at least one:

http://forum.hibernate.org/viewtopic.ph ... t=reattach

Thanks for your time.
Ricardo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.