如何在JPA 2.1中指定实体映射?

Haj*_*cke 8 java orm jpa

JPA 2.0的实体映射文件的正确起始标记是

<entity-mappings version="1.0" 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
    http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
Run Code Online (Sandbox Code Playgroud)

JPA 2.1需要更正哪些内容?

我试过了

<entity-mappings version="2.1" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm">
Run Code Online (Sandbox Code Playgroud)

但是这给出了错误:

文档中没有引用语法约束(DTD或XML Schema).

Dat*_*eus 8

根据JPA 2.1规范所说的可能;-)或JPA 2.1实现文档告诉你

将java.sun.com更改为xmlns.jcp.org

orm_1_0更改为orm_2_1

将version ="1.0"更改为version ="2.1"


mal*_*c4k 6

根据官方文档,第12.3XML模式

<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
      http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
    version="2.1">
      ...
</entity-mappings>
Run Code Online (Sandbox Code Playgroud)