public class HibernateSessionProvider implements SessionProvider, Disposable {
private SessionFactoryProvider sessionFactoryProvider;
private Session session;
public SessionFactoryProvider getSessionFactoryProvider() { return this.sessionFactoryProvider; }
public void setSessionFactoryProvider(SessionFactoryProvider sessionFactoryProvider) {
this.sessionFactoryProvider = sessionFactoryProvider;
}
public Session getSession() throws PersistenceException {
if ((this.session == null) || (!this.session.isOpen())) {
try {
return this.sessionFactoryProvider.getSessionFactory().openSession();
} catch (HibernateException he) {
throw new PersistenceException("HibernateException caught building hibernate hibernate", he);
}
}
return this.session; }
public void dispose() {
if ((this.session != null) && (this.session.isOpen()) && (this.session.isConnected()) {
try {
this.session.flush();
this.session.connection().commit();
this.session.close();
} catch (Exception e) {
// do something
}
}
} }
Is there anything wrong with doing it this way? All of the components needing a Hibernate session (Persistence Manager and DAOs) are scoped at the same level. SessionFactoryProvider is another component but scoped at the application.
Cheers, matthew
------------------------------------------------------- This SF. Net email is sponsored by: GoToMyPC GoToMyPC is the fast, easy and secure way to access your computer from any Web browser or wireless device. Click here to Try it Free! https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork