hibernate连接工具类
2016-07-13 21:03
197 查看
<span style="font-size:14px;">package com.yfly.hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* hibernate连接
* @author yFly
*
*/
public class HibernateUtils {
private static SessionFactory sessionFactory;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession() {
return sessionFactory.openSession();
}
public static void close(Session session) {
if(session != null) {
if(session.isOpen()) {
session.close();
}
}
}
}
</span>
jia包:...
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* hibernate连接
* @author yFly
*
*/
public class HibernateUtils {
private static SessionFactory sessionFactory;
static {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession() {
return sessionFactory.openSession();
}
public static void close(Session session) {
if(session != null) {
if(session.isOpen()) {
session.close();
}
}
}
}
</span>
jia包:...
相关文章推荐
- 详解Asytask和Handler的区别和使用方法
- Windows Azure HandBook (8) Azure性能测试(1)
- 自助法在分散式投资策略中的应用
- Hdu 5348 MZL's endless loop (构造)
- jquery基础知识
- Ubuntu串口问题(2)
- 编译内核提示mkimage command not found – U-Boot images will not be built
- Android自定义一个时间轴,通过ListView来实现时间轴的效果
- 【Spring 1】Spring简介
- jQuery学习笔记之ajax
- 【Spring 1】Spring简介
- typedef 和define 的区别
- JAVA8之lambda表达式详解,及stream中的lambda使用
- .gitignore java 版本
- 素问篇-经络论
- 【华为OJ】数字颠倒
- XSS攻击原理以及解决办法
- android-----HandlerThread的使用
- 用户权限管理
- 最基础的——windows下命令行操作(本博客将不断更新)