Error using the getCurrentSession method of SessionFactory

0

I create a factory session in the following way:

private final SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").addResource("com/jegab/persistenceEntities/Categoria.hbm.xml").buildSessionFactory();

When wanting to get a session in Hibernate I am using the following line of code:

Session session = sessionFactory.getCurrentSession();

You are returning an error that says:

javax.faces.el.EvaluationException: org.hibernate.HibernateException: No CurrentSessionContext configured!

help.

    
asked by Andresr 17.09.2017 в 01:13
source

1 answer

1

It was a matter of adding this property in true to the hibernate.cfg.xml file:

<property name="hibernate.current_session_context_class">thread</property>
    
answered by 17.09.2017 в 02:03