1 16 17 package org.springframework.orm.hibernate3; 18 19 import org.hibernate.HibernateException; 20 import org.hibernate.classic.Session; 21 import org.hibernate.context.CurrentSessionContext; 22 import org.hibernate.engine.SessionFactoryImplementor; 23 24 44 public class SpringSessionContext implements CurrentSessionContext { 45 46 private final SessionFactoryImplementor sessionFactory; 47 48 49 53 public SpringSessionContext(SessionFactoryImplementor sessionFactory) { 54 this.sessionFactory = sessionFactory; 55 } 56 57 60 public Session currentSession() throws HibernateException { 61 try { 62 return (org.hibernate.classic.Session) SessionFactoryUtils.doGetSession(this.sessionFactory, false); 63 } 64 catch (IllegalStateException ex) { 65 throw new HibernateException(ex.getMessage()); 66 } 67 } 68 69 } 70 | Popular Tags |