hiberante.hbm2ddl.auto参数配置
2016-01-27 09:45
204 查看
hibernate.cfg.xml的配置:
hibernate.hbm2ddl.auto :可以通过hibernate的*.hbm.xml的配置来动态创建数据库的表结构(通过DDL语言)
可配置属性值:create-drop|create|update|validate
create-drop:表示在hebarinate初始化时创建表格,程序运行结束的时候会删除相应的表格
create:在hibernate每次初始化时会都会重新创建表格,在运行结束之后不删除表格
update:只是根据映射文件去验证数据库中的表,如果不一致,就更新表的结构
validate:只是根据映射文件去验证数据库中的表,不一致只是报错而不更新数据库表结构
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">org.hsqldb.jdbcDriver</property> <property name="connection.url">jdbc:hsqldb:hsql://localhost</property> <property name="connection.username">sa</property> <property name="connection.password"></property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.HSQLDialect</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">update</property> <mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/> </session-factory> </hibernate-configuration>
hibernate.hbm2ddl.auto :可以通过hibernate的*.hbm.xml的配置来动态创建数据库的表结构(通过DDL语言)
可配置属性值:create-drop|create|update|validate
create-drop:表示在hebarinate初始化时创建表格,程序运行结束的时候会删除相应的表格
create:在hibernate每次初始化时会都会重新创建表格,在运行结束之后不删除表格
update:只是根据映射文件去验证数据库中的表,如果不一致,就更新表的结构
validate:只是根据映射文件去验证数据库中的表,不一致只是报错而不更新数据库表结构
相关文章推荐
- 如何在Mac OS中安装 wget
- 空间点到直线的距离【转】
- easyui datagrid 动态添加、移除editor
- Android退出应用最优雅的方式(改进版)
- jQuery学习之旅 4 细说DOM操作
- 解决db2 SQL30081N
- [易飞]关于内部备料订单动态跟踪库存和销货量的统计
- jquery中Live方法不可用,Jquery中Live方法失效
- Ueditor 编译发布后无法使用上传图片、附件等功能
- 初识IntPtr
- swift自学笔记(四)(懒加载、存储属性、计算属性、类属性、属性监听)
- 威联通 NAS TS-212P 重置初始化
- jQuery placeholder插件 让IE也能够支持placeholder属性
- WPF后台更改样式
- Mac OS X 命令行窗口使用 rar/unrar 命令
- Mac os(OS X EI Capitan)下PHP安装Mcrypt扩展
- 判断点是否在三角形内【转】
- Linux I/O篇
- 线程基础:线程池(6)——基本使用(中)
- 项目环境的搭建