2.一对一双向主键关联(人对身份证) 工具类
2016-03-25 14:17
375 查看
package com.bjpowernode.hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtils { private static SessionFactory factory; static { try { //读取hibernate.cfg.xml文件 Configuration cfg = new Configuration().configure(); //建立SessionFactory factory = cfg.buildSessionFactory(); }catch(Exception e) { e.printStackTrace(); } } public static Session getSession() { return factory.openSession(); } public static void closeSession(Session session) { if (session != null) { if (session.isOpen()) { session.close(); } } } public static SessionFactory getSessionFactory() { return factory; } } package com.bjpowernode.hibernate; import org.hibernate.cfg.Configuration; import org.hibernate.tool.hbm2ddl.SchemaExport; /** * 将hbm生成ddl * @author Administrator * */ public class ExportDB { public static void main(String[] args) { //默认读取hibernate.cfg.xml文件 Configuration cfg = new Configuration().configure(); SchemaExport export = new SchemaExport(cfg); export.create(true, true); } }
相关文章推荐
- Android程序中输入法弹出的时候如何不遮挡输入,与布局相配
- Gulp使用指南
- Win8.1如何删除美式键盘?Win8.1系统删除美式键盘的方法
- VC中单文件和多文档文件的创建流程和打开流程
- 唱吧免费导出歌曲mp3和MV
- ACCP 结业考试
- 服务器出现500错误,报el表达式错误
- spark集群安装与配置
- android eclipse 开发工具的使用
- 海量数据top K问题
- 写一个程序,用于分析一个字符串中各个单词出现的频率,并将单词和它出现的频率输出显示。(单词之间用空格隔开,如“Hello World My First Unit Test”)
- 把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”
- 用不动点组合子解递归(python实现)
- uuid
- Cocos2d-js Chipmunk的使用,实现一根绳子
- MySQL权限篇之EVENT及EXECUTE
- 【LeetCode】206. Reverse Linked List
- Zabbix部署(一)
- iOS完整App资源收集
- php static静态属性、java static属性变量的区别