Hibernate4工具类的封装
来源:互联网 发布:斗米兼职 知乎 编辑:程序博客网 时间:2024/05/21 11:01
package com.luo.utils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static SessionFactory sessionFactory;
public static Session getSession(){
return getSessionFactory().getCurrentSession();
}
public static SessionFactory getSessionFactory(){
if (sessionFactory ==null || sessionFactory.isClosed()) {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
return sessionFactory;
}
}
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static SessionFactory sessionFactory;
public static Session getSession(){
return getSessionFactory().getCurrentSession();
}
public static SessionFactory getSessionFactory(){
if (sessionFactory ==null || sessionFactory.isClosed()) {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
return sessionFactory;
}
}
0 0
- Hibernate4工具类的封装
- hibernate4.0以上的hibernateUtil工具类
- hibernate4的dao基础工具类
- hibernate4的dao层工具类
- 封装的工具类
- 工具类的封装-sharePreference的封装
- Hibernate4 针对存储过程的接口封装
- 工具类的封装--Log封装
- 工具类的封装--SharedPreferences封装
- solrj工具类的封装
- 封装的JDBC工具类
- JDBC工具类的封装
- Ehcache封装的工具类
- 分页的封装工具类
- 封装的log工具类
- 封装的HttpClient工具类
- redis的工具类封装
- 封装SharedPreferences的工具类
- PHP与MySQL学习与实践— —新闻系统前后端
- 1.线性表创建、元素插入、元素删除、线性表合并(原创)
- 成功在家用ssh远程连上了学校电脑虚拟机当中的ubuntu(代价是虚拟机全部黑屏只能用SSH连接了!)
- API之进程和线程函数
- 一、String类的基础
- Hibernate4工具类的封装
- 第六章思考题
- 十二、图的遍历--(2)深度优先搜索算法
- Android复杂ListView
- C/C++ const
- Windows配置Android的JNI开发环境
- Java数据结构:栈的实现
- Java多线程编程中Future模式的详解
- 学习之道