📄 hibernatesessionhelper.java
字号:
package org.helpsoft;
import com.helpsoft.util.log.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.Query;
import org.helpsoft.entity.hy.*;
import org.helpsoft.entity.hyklx.*;
import org.helpsoft.entity.hyxf.*;
import org.helpsoft.entity.sp.*;
import org.helpsoft.entity.splb.*;
import org.helpsoft.entity.czk.*;
import org.helpsoft.entity.tx.*;
import org.helpsoft.entity.zkk.*;
import org.helpsoft.entity.xfmx.*;
/**
* This class is a Helper for the Hibernate Sessions.
*
* @author cao guangxin - www.relationinfo.com
*/
public class HibernateSessionHelper {
/**
* The logger
*/
private static Logger log = LogService.getLogger(HibernateSessionHelper.class);
/**
* The Hibernate configuration.
*/
private static Configuration cfg;
/**
* The Hibernate session factory.
*/
private static SessionFactory sf;
static {
try {
cfg = new Configuration().configure();
sf = cfg.buildSessionFactory();
} catch (Exception e) {
log.fatal("Error while configuring the hibernate beans", e);
}
}
/**
* Get a hibernate session.
*/
public static Session getHibernateSession() throws Exception
{
Session session = sf.openSession();
return session;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -