I am getting the following error. I searched google. They are giving the answer to add the following element(in bold) for the error. I have added it to the hibernate.cfg.xml file. I am still getting the same error I pasted below.
<property name="current_session_context_class">thread</property> Error StackQuote:
Step 1
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See
http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Step 2Exception in thread "main"
Sesssion Factory value org.hibernate.impl.SessionFactoryImpl@104c575
org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)
CodeCode:
public class Main {
public static void main(String[] args)
{
System.out.println("Step 1");
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
System.out.println("Step 2");
System.out.println("Sesssion Factory value "+sessionFactory);
Session session = sessionFactory.getCurrentSession(); //Error is occuring at this line
System.out.println("Step 3"); // This line is not being displayed
hibernate.cfg.xmlCode:
<hibernate-configuration>
<session-factory>
<!-- hibernate dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.ProgressDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://127.0.0.1:5432/testdb</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">venkat7</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<mapping resource="com/sample/Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>