在JPA配置中设置默认模式名称使用​​Spring Boot for Eclipselink吗?

时间:2019-03-15 05:47:43

标签: java spring-boot jdbc eclipselink

我正在尝试使用Eclipslink和Spring boot 2.x在JPA配置中配置默认​​架构属性

旧代码(可以正常工作):

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
    <persistence-unit-defaults>
        <schema>SECURITY</schema>
    </persistence-unit-defaults>
</persistence-unit-metadata>

但是如何使用Spring引导方式进行配置。

我可以在模型上添加架构标记的一种方法

@Entity
@Table(name = "USER",schema="SECURITY")
public class User implements Persistable<String> {
...
@Id
public String getId() {
    return id;
}

但这不是我想要的解决方案,因为如果在具有不同架构的不同应用程序中使用相同的实体模型,它将无法正常工作。

我发现了一个专门用于休眠的属性

spring.jpa.properties.hibernate.default_schema

但是Spring Boot中的Eclipselink是否具有类似的属性?我最近将Spring mvc应用程序迁移到了Spring Boot中,但是遇到了这个问题。

0 个答案:

没有答案