0

I am new to hibernate technology and I am facing with the problem specified in the title. I have read all day about how to solve my problem, but I failed to solve it. I would really appreciate anyone who can help me. Below is my code.

SessionUtil.java

import org.hibernate.Session;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;

public class SessionUtil {

    private static SessionUtil instance=new SessionUtil();
    private SessionFactory sessionFactory;

    public static SessionUtil getInstance(){
            return instance;
    }

    //@SuppressWarnings("deprecation")
    private SessionUtil(){
        Configuration configuration = new Configuration();
        configuration.configure("hibernate.cfg.xml");

        sessionFactory = configuration.buildSessionFactory();
    }

    public static Session getSession(){
        Session session =  getInstance().sessionFactory.openSession();

        return session;
    }
}

Thank you!

Abaya
  • 47
  • 1
  • 8
  • I have already read and tried the suggestions there, but they didn't solve my problem. – Abaya Apr 23 '17 at 16:49
  • Then ask about why it did not solve your problem please. The method is deprecated, and the suggestion there is the alternative method that should be used. – infiniteRefactor Apr 23 '17 at 16:53

0 Answers0