⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hibernateutil.java

📁 are are are are are are are are are are are are
💻 JAVA
字号:
/* * HibernateUtil.java * * Created on 2006年5月1日, 下午8:31 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package enova.util;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.hibernate.*;import org.hibernate.cfg.*;/** * * @author vlinux */public class HibernateUtil {        private static Log log = LogFactory.getLog(HibernateUtil.class);    private static final SessionFactory sessionFactory;        static {        try {            sessionFactory = new Configuration().configure()            .buildSessionFactory();        } catch (Throwable ex) {            log.error("Initial SessionFactory creation failed.", ex);            throw new ExceptionInInitializerError(ex);        }    }        public static final ThreadLocal session = new ThreadLocal();        public static Session currentSession() {        Session s = (Session) session.get();        if (s == null) {            s = sessionFactory.openSession();            session.set(s);        }        return s;    }        public static void closeSession() {        Session s = (Session) session.get();        if (s != null)            s.close();        session.set(null);    }        /**     * Creates a new instance of HibernateUtil     */    public HibernateUtil() {    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -