hibernate.cfg.xml 和每张表对应的hbm文件 生成数据库表
来源:互联网 发布:洪拳小子知乎 编辑:程序博客网 时间:2024/04/29 04:28
电脑重装系统忘记备份数据库了。 用项目里面的 hibernate.cfg.xml 和每张表对应的hbm文件 生成数据库表的代码:
import java.io.File;import org.hibernate.HibernateException;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.tool.hbm2ddl.SchemaExport;public class HibernateSchemaExport { static Session session; static Configuration config = null; static Transaction tx = null; public static void main(String[] args) { try { config = new Configuration().configure(new File( "src/hibernate.cfg.xml")); System.out.println("Creating tables..."); SessionFactory sessionFactory = config.buildSessionFactory(); session = sessionFactory.openSession(); tx = session.beginTransaction(); SchemaExport schemaExport = new SchemaExport(config); schemaExport.create(true, true); System.out.println("Table created."); tx.commit(); } catch (HibernateException e) { e.printStackTrace(); try { tx.rollback(); } catch (HibernateException e1) { e1.printStackTrace(); } } finally { } }}
- hibernate.cfg.xml 和每张表对应的hbm文件 生成数据库表
- 通过Hibernate的hbm.xml文件生成数据库表
- 通过Hibernate的hbm.xml文件生成数据库表
- 使用hibernate连接mysql数据库正向工程hibernate.cfg.xml文件和xxx.hbm.xml配置文件
- Eclipse 用Hibernate Tools 生成 .hbm cfg.xml等文件
- Eclipse 用Hibernate Tools 生成 .hbm cfg.xml等文件 .
- Eclipse 用Hibernate Tools 生成 .hbm cfg.xml等文件
- Hibernate连接SQL Server2008时候hibernate.cfg.xml和table.hbm.xml文件的配置详情
- Hibernate配置文件hibernate.cfg.xml、类与表间的关系映射文件Student.hbm.xml的书写和属性注解
- hibernate 的cfg.xml 和 hbm.xml文档基本配置
- hibernate.cfg.xml和.hbm.xml
- Event.hbm.xml和hibernate.cfg.xml
- Hibernate Tools-代码生成cfg.xml,hbm.xml和持久類
- Hibernate.cfg.xml配置Hibernate连接数据库和对应的数据表
- 深入学习Hibernate4_02 hibernate.cfg.xml文件和xxx.hbm.xml文件详解
- hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
- hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
- hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
- Ubuntu下获取android源码
- 计算机软件著作权
- 线性表应用举例——一元多项式相加问题
- 在做Drupal开发的时候,需要查看的相关日志
- CSDN专访:做一个有节操的开发者
- hibernate.cfg.xml 和每张表对应的hbm文件 生成数据库表
- hrome登陆12306跳过证书下载
- java内部类种类
- 虚拟索引
- AES加密算法在Linux下出现随机加密结果
- EL表达式
- OpenGL之旅
- MIT OS 6. Start-VMM@ Lab2
- POJ1493