RE: Hibernate

"Luke Galea" <[email protected]>
Newsgroups gmane.comp.java.tapestry.devel
Message-ID <[email protected]>
I had figured that I would just use a singleton to store the
SessionFactory. That seems to be working so far. 

The very end of the hibernate docs say: "When using a servlet only, you
may reuse the same session for multiple client requests. Just remember
to disconnect the session before returning control to the client."

That leaves me to believe there is some reason not to hold open a
session for an entire Visit... What do you think of just placing it in
the request cycle? Then somewhere putting something to close it before
completing the render of the entire page.. not sure how to accomplish
this.. just an idea.

Has anyone else had success?

Luke Galea 
Software Development
BlueCat Networks
905-762-5225
 

-----Original Message-----
From: Eric Everman [mailto:[email protected]] 
Sent: November 12, 2002 7:01 PM
To: Luke Galea; Tapestry Developer
Subject: Re: [Tapestry-developer] Hibernate

Hi Luke-

I'm new to Tapestry, but have been using Hibernate for a while, so your 
questions struck a chord with me.  I am planning a Hibernate / Tapestry 
demo project, just so I can try combining the two.

My current thinking for accessing the SessionFactory is to place it in
the 
servlet application context at startup via a custom Tapestry 
Servlet.  Hibernate sessions would be created as needed for each client
and 
stored in their Visit object.  Sessions are light weight, serializable,
and 
'detachable' from the database, so I'm planning on allowing a client to 
keep the same session until their Visit is GC'ed.

Each action on the part of the client involving Hibernate would then
access 
the new or existing session, re-attach it to the db, *do stuff*, flush
to 
db, then detach.

Out of all of this, the part that seems most cumbersome is the need to 
access the servlet context for a global variable - it really seems like 
Tapestry should provide easier access to application level variables.

Cheers,

Eric Everman


At 11/12/2002, Luke Galea wrote:

>Hello..
>
>We are using Hibernate for our project.. and I am looking at using the 
>contrib Table component with Hibernate. As I know I am not the first to

>use Tapestry with Hibernate I have a few questions.
>
>
>    * Has anyone implemented a Hibernate-centric version of the Table 
> Model? Is there interest in such a thing being developed and added to
the 
> contrib?
>    * Where is the best place to store the Hibernate session so it can
be 
> used through the request.. should it be place in the request cycle?
How 
> should I ensure that it is closed before the cycle completes?



-------------------------------------------------------
This sf.net email is sponsored by: Are you worried about 
your web server security? Click here for a FREE Thawte 
Apache SSL Guide and answer your Apache SSL security 
needs: http://www.gothawte.com/rd523.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.