/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

  1. package org.sqlproc.engine.hibernate;
  2. import org.hibernate.SessionFactory;
  3. import org.sqlproc.engine.SqlSession;
  4. import org.sqlproc.engine.SqlSessionFactory;
  5. /**
  6. * The simple implementation of the factory {@link SqlSessionFactory} for the Hibernate stack. This implementation is
  7. * sutable mainly for Web applications.
  8. *
  9. * <p>
  10. * For more info please see the <a href="https://github.com/hudec/sql-processor/wiki">Tutorials</a>.
  11. *
  12. * @author <a href="mailto:Vladimir.Hudec@gmail.com">Vladimir Hudec</a>
  13. */
  14. public class HibernateWebSessionFactory implements SqlSessionFactory {
  15. /**
  16. * The Hibernate session factory.
  17. */
  18. private SessionFactory sessionFactory;
  19. /**
  20. * Creates a new instance.
  21. *
  22. * @param sessionFactory
  23. * the Hibernate session factory
  24. */
  25. public HibernateWebSessionFactory(SessionFactory sessionFactory) {
  26. super();
  27. this.sessionFactory = sessionFactory;
  28. }
  29. /**
  30. * {@inheritDoc}
  31. */
  32. @Override
  33. public SqlSession getSqlSession() {
  34. return HibernateSession.generateProxy(sessionFactory.getCurrentSession());
  35. }
  36. }