Created
July 24, 2012 02:31
-
-
Save pengju/3167647 to your computer and use it in GitHub Desktop.
hibernate中的工具类,生成sessionFactory和session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kaishengit.util; | |
import org.hibernate.Session; | |
import org.hibernate.SessionFactory; | |
import org.hibernate.cfg.Configuration; | |
public class HibernateUtil { | |
private HibernateUtil() {}; | |
private static Configuration cfg = new Configuration().configure(); | |
private static SessionFactory factory = cfg.buildSessionFactory(); | |
public static SessionFactory getFactory (){ | |
return factory; | |
} | |
public static Session getSession () { | |
return factory.getCurrentSession(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment