Hibernate.cfg.xml配置文件中的hbm2ddl.auto属性

来源:互联网 发布:gta5购买正版淘宝网 编辑:程序博客网 时间:2024/05/27 00:42

该属性用于设置创建SessionFactory时,指定根据持久化类的映射关系操作数据库表。该属性值可以为:validate、update、create和create-drop四个值

    create: 每次创建SessionFactory时都会重新创建映射的所有数据表    update:每次创建SessionFactory时会检查下对应的数据库里是否已存在与持久化类对应的表,如果没有就create创建,如果有就update或者insert更新或者插入    create-drop:每次程序调用close()显式关闭SessionFactory时,会自动drop这一次创建的所有的数据表

一般使用update值比较常用:

<property name="hibernate.hbm2ddl.auto>update</property>
0 0