Hibernate SessionFactory
来源:互联网 发布:mac 安装java环境 编辑:程序博客网 时间:2024/05/24 01:49
1 使用configuration对象创建sessionFactory对象
(1)创建sessionfactory过程中做事情:
- 根据核心配置文件中,有数据库配置,有映射文件部分,到数据库里面根据映射关系把表创建
2 创建sessionFactory过程中,这个过程特别耗资源的
(1)在hibernate操作中,建议一个项目一般创建一个sessionFactory对象
//hibernate帮创建表,需要配置之后才可
//update:如果已经有表,则更新表,如果没有表,则创建
《property name=”hibernate.hbm2ddl.auto”>update《/property》
3 具体实现
(1)写工具类,写静态代码块实现
* 静态代码块在类加载时候执行,执行一次
public class HibernateUtils { private static Configuration cfg = null; private static SessionFactory sf =null; static{ cfg = new Configuration(); cfg.configure(); sf=cfg.buildSessionFactory(); } public static SessionFactory getSessionFactory(){ return sf; } public static Session getSession(){ return sf.getCurrentSession(); }}
阅读全文
0 0
- SessionFactory (org.hibernate.SessionFactory)
- hibernate SessionFactory
- Hibernate SessionFactory
- Hibernate SessionFactory
- Hibernate的Transaction SessionFactory
- Hibernate中SessionFactory配置
- Hibernate之SessionFactory
- hibernate support sessionFactory 注入
- Hibernate SessionFactory配置实例
- hibernate sessionFactory(转)
- Hibernate 关闭sessionFactory
- Hibernate 的 SessionFactory接口
- Hibernate中SessionFactory配置
- Hibernate SessionFactory与Session
- hibernate之SessionFactory
- Hibernate中SessionFactory配置
- hibernate怎样创建SessionFactory
- hibernate 4.3 SessionFactory
- C语言获取系统时间 & 精度
- github获取token
- Spring学习笔记 Spring Roo 简介
- forward 和redirect的区别
- JavaScript requestAnimationFrame动画
- Hibernate SessionFactory
- 【Web开发的架构】
- 什么时候使用CountDownLatch
- web前端综合性总结
- SpringMVC学习(三)映射请求参数&请求参数
- HTTP cookies 讲解(HTTP cookies explained )
- Nginx
- Poj 1985 Cow Marathon ( 树的直径
- kNN在CIFAR10上的应用