HibernateUtil工具类

public class HibernateUtil {

    private static SessionFactory sessionFactory;

    static {
        Configuration configure = new Configuration().configure("hibernate.cfg.xml");
        sessionFactory = configure.buildSessionFactory();

    }

    public static Session openSession() {
        return sessionFactory.getCurrentSession();
    }
}

你可能感兴趣的:(HibernateUtil工具类)