Hibernate自动创建表

您所在的位置:网站首页 域名查询知乎 Hibernate自动创建表

Hibernate自动创建表

2023-03-13 19:56| 来源: 网络整理| 查看: 265

表结构和数据总是在程序执行的时候无端的修改,折腾了好长时间,查了很长时间hibernate的数据库映射文件和接口程序,始终没有发现有什么错误,到最后才发现了它!           解释如下:

hibernate.hbm2ddl.auto Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly. eg. validate | update | create | create-drop

其实这个参数的作用主要用于:自动创建|更新|验证数据库表结构。如果没有此方面的需求建议value="none".

其它几个参数的意思:

validate               加载hibernate时,验证创建数据库表结构create                  每次加载hibernate,重新创建数据库表结构create-drop        加载hibernate时创建,退出是删除表结构update                 加载hibernate自动更新数据库结构



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3