2013-06-14 33 views
6

Thẻ khởi đầu chính xác cho các tập tin ánh xạ thực thể cho JPA 2.0 làCách chỉ định ánh xạ thực thể trong JPA 2.1?

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

gì là sự điều chỉnh cần thiết cho JPA 2.1?

tôi đã cố gắng

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

Nhưng điều này mang đến cho các lỗi:

No grammar constraints (DTD or XML Schema) referenced in the document.

+1

tha t là thẻ bắt đầu cho JPA 1.0 không 2.0 –

Trả lời

1

Đối với phiên bản 2.1 như sau đang làm việc:

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

Theo official documentation, phần 12.3 Lược đồ XML:

<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> 
Các vấn đề liên quan