2.复合主键:工具类
2016-06-22 08:58
323 查看
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 N实现分屏
- jquery实现返回顶部特效
- 如何黑掉Telegram 以及WhatsApp?
- poj-3254 Corn Fields(状压dp)
- Win7下使用无线网卡共享上网的4种方式
- 一步一步写平衡二叉树(AVL树)
- 我需要什么样的数据库访问类?
- C++03、条件编译
- 记录一些开源项目和一些需要的文章
- linux 查看系统和内核版本
- 静态页面html中跳转传值的JS处理技巧
- Tomcat如何修改执行窗口的标题
- 1.复合主键:Object,hbm
- BAT 批处理脚本 教程
- Linux启动界面切换:图形界面-字符界面
- Android深度系列—分析Android-Universal-Image-Loader的缓存处理机制
- Java的字符读写类CharArrayReader和CharArrayWriter使用示例
- Preflight【预检】
- Eclipse 安装SVN插件
- jq 自动滑动轮换(向后插入小块)