beehive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrian Grealish" <>
Subject RE: Hibernate Goodies
Date Thu, 09 Dec 2004 03:08:57 GMT

I have got my beehive web application to use the Hibernate control but I
am running into a problem with the Hibernate session being closed for
subsequent requests. Works for one call only.

>From reading the tutorial I thought the session was associated with the
ThreadLocal and will be created/opened on request. I'm confused about
what to do with the session once it's been used. From reading the
tutorial we don't have to close the session as the control manages that.
The next time I call my control I get a session is closed exception.

I've included my code in it's simplest form below, should I be checking
to see if the session is closed and calling reconnect each time? Doesn't
this defeat the point of using the ThreadLocal?

What am I missing here?


public class TestOwnersSessionImpl implements TestOwnersSession

    @org.apache.beehive.controls.api.context.Context ControlBeanContext
    @org.apache.beehive.controls.api.context.Context ResourceContext

    HibernateControl hibernate;

    public List selectTestOwners() {
    	List testOwners = null;
    	try {
    		Session session = hibernate.getSession();
    		testOwners = session.find("from TestOwner");
    	}catch(HibernateException ex) {
    	return testOwners;


-----Original Message-----
From: Dan Diephouse [] 
Sent: Monday, December 06, 2004 1:10 PM
Subject: Hibernate Goodies

Howdy all,

I know there are hibernate users out there and I would like to invite 
you test the hibernate control.  I've just added in managed 
transactions, so the control will take care of starting/committing your 
transactions as well as session management.  I look forward to any 
feedback that you have (on documentation, code, api, etc)!


Snapshot jar:

(you should just need to drop this into your build to be able to use it.

For the hibernate dependencies see the hibernate documentation.)


- Dan

Dan Diephouse
Envoi Solutions LLC

View raw message