JPA persistence.xml 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值