jpa执行sql脚本
您可以在将在运行时执行的JPA持久性上下文定义中定义并链接到SQL脚本。 有标准化的属性来定义脚本,以分别说明如何创建模式,批量加载数据和删除模式:
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="prod" transaction-type="JTA">
<properties>
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
<property name="javax.persistence.schema-generation.create-script-source"
value="create-schema.sql" />
<property name="javax.persistence.schema-generation.sql-load-script-source"
value="load-data.sql" />
<property name="javax.persistence.schema-generation.drop-script-source"
value="drop-schema.sql" />
</properties>
</persistence-unit>
</persistence>
SQL文件应驻留在类路径中。
这篇帖子从我的新闻通讯004中转贴了
翻译自: https://www.javacodegeeks.com/2017/12/jpa-persistence-xml-sql-script-definitions.html
jpa执行sql脚本
1957




被折叠的 条评论
为什么被折叠?



