hibersession.java

来自「一个小型的购物商店」· Java 代码 · 共 46 行

JAVA
46
字号
/* * HiberSession.java * * Created on 2006年9月26日, 下午7:31 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package com.shopping.resource;import org.hibernate.*;import org.hibernate.cfg.*;/** * * @author 曹昊 */public class HiberSession {    private static SessionFactory sf = null;    static {        Configuration cfg = new Configuration();        sf = cfg.configure("com/shopping/hibernate/hibernate.cfg.xml").buildSessionFactory();    }        /**     *得到SessionFactory     */    public static SessionFactory getSf() {        return sf;    }         /**      *得到Session      */    public static Session getSession(){        Session sess=getSf().openSession();        return sess;    }        /** Creates a new instance of HiberSession */    private HiberSession() {    }    }

⌨️ 快捷键说明

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