How to specify entity mappings in JPA 2.1?

The correct start tag for the entity mapping file for JPA 2.0 was

<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"> 

What are the required fixes for JPA 2.1?

I tried

 <entity-mappings version="2.1" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"> 

But this gives an error:

There are no grammar restrictions in the document (DTD or XML Schema).

+6
source share
3 answers

According to what the JPA 2.1 specification says maybe ;-) or JPA 2.1 implementation docs that tell you

Change java.sun.com to xmlns.jcp.org

Change orm_1_0 to orm_2_1

Change version = "1.0" to version = "2.1"

+6
source

According to the official documentation section 12.3 XML Schema :

 <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> 
+3
source

For version 2.1, the following works:

 <?xml version="1.0" encoding="UTF-8" ?> <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"> 
+1
source

Source: https://habr.com/ru/post/947288/


All Articles