jpa 脚本生成数据库以及数据完整

时间:2021-12-14 21:42:29
<prop key="hibernate.hbm2ddl.import_files_sql_extractor"> org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor</prop> <!--系统执行create语句的时间点之前(then),当时间点选择为metadata则使用自动生成,设置为script则完全由脚本生成.--> <prop key="javax.persistence.schema-generation.create-source">script-then-metadata</prop> <!--系统执行drop语句的时间点之后m-then-s--> <prop key="javax.persistence.schema-generation.drop-source">metadata-then-script</prop> <!--在所有的create之后,用于insert数据--> <prop key="javax.persistence.schema-generation.load-source">metadata-then-script</prop> <prop key="javax.persistence.schema-generation.create-script-source">jpa_boot_script/CreateScript.sql</prop> <prop key="javax.persistence.schema-generation.drop-script-source">jpa_boot_script/DropScript.sql</prop> <prop key="javax.persistence.sql-load-script-source">jpa_boot_script/LoadScript.sql</prop> 添加表级约束可以用,@Check,多列唯一可以在@Table(uniqueConstrains)自定 @Column(columnDefinitions)用于定义一列的check约束.