I\'m trying to access the current hibernate session in a test case, and getting the following error:
org.hibernate.HibernateException: No Hibernate
With the above Spring configuration, it should be sufficient to code
Session session = sessionFactory.getCurrentSession();
in your method and class to test. Session management is done by the Hibernate / Spring /JUnit test configuration, as later is done in the Hibernate / Spring configuration in the real application.
This is how it worked for my tests. In the final web application there will automatically be a Hibernate session associated with the current web request and therefore in testing there should be no sessionFactory.openSession()
call.