/sql-processor-hibernate/src/main/java/org/sqlproc/engine/hibernate/HibernateWebSessionFactory.java
http://github.com/hudec/sql-processor · Java · 41 lines · 15 code · 5 blank · 21 comment · 0 complexity · b93ea6a362379bc159cb59a20b8ffe51 MD5 · raw file
- package org.sqlproc.engine.hibernate;
- import org.hibernate.SessionFactory;
- import org.sqlproc.engine.SqlSession;
- import org.sqlproc.engine.SqlSessionFactory;
- /**
- * The simple implementation of the factory {@link SqlSessionFactory} for the Hibernate stack. This implementation is
- * sutable mainly for Web applications.
- *
- * <p>
- * For more info please see the <a href="https://github.com/hudec/sql-processor/wiki">Tutorials</a>.
- *
- * @author <a href="mailto:Vladimir.Hudec@gmail.com">Vladimir Hudec</a>
- */
- public class HibernateWebSessionFactory implements SqlSessionFactory {
- /**
- * The Hibernate session factory.
- */
- private SessionFactory sessionFactory;
- /**
- * Creates a new instance.
- *
- * @param sessionFactory
- * the Hibernate session factory
- */
- public HibernateWebSessionFactory(SessionFactory sessionFactory) {
- super();
- this.sessionFactory = sessionFactory;
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public SqlSession getSqlSession() {
- return HibernateSession.generateProxy(sessionFactory.getCurrentSession());
- }
- }