Hibernate主配置文件(hibernate.cfg.xml)

来源:互联网 发布:浙师大行知学院怎么样 编辑:程序博客网 时间:2024/06/04 23:19

可参考${hibernate}/project/etc/hibernate.properties

一、数据库连接信息(五项,可省略hibernate.)

       <property  ......>

        1、hibernate.dialect                                                                   方言         

        2、hibernate.connection.driver_class                                    连接驱动

        3、hibernate.connection.url                                                      连接url

        4、hibernate.connection.username                                       用户名

        5、hibernate.connection.password                                        密码

二、导入映射文件

       <mapping resource="classPath">                                       映射文件位于classpath下

或   <mapping  file="filePath">                                                     映射文件位于硬盘路径下

三、其他

          <property  ......>

      1、<property name="show_sql">true</property>                                                  显示生成的sql语句

      2、<property name="format_sql">true</property>                                                格式化生成的sql语句

      3、<property name="hbm2ddl.auto">update</property>                                     根据映射文件创建数据库表

                 create-drop                        加载hibernate时创建,关闭SessionFactory时删除表结构                                            

                 create                                   每次加载hibernate,重新创建数据库表结构

                 update                                  最常用的属性,表不存在则创建,不同即更新(测试时使用)

                 validate                                加载hibernate时,验证表结构(上线时使用)

0 0
原创粉丝点击