jpa自动创建数据库表

jPA自动创建数据库表的一些配置

不打扰是莪最后的温柔 提交于 2019-12-01 07:13:58
jPA自动创建数据库表的一些配置 hibernate.cfg.xml 中hibernate.hbm2ddl.auto配置节点如下: <properties> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.hbm2ddl.auto" value="create" /> </properties> Hibernate Reference Documentation 3.3.1解释如下: 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 其实这个hibernate.hbm2ddl.auto参数的作用主要用于:自动创建|更新|验证数据库表结构。如果不是此方面的需求建议set value="none"。 create: