META-INF/orm.xml.xsd您不必手动映射每一列 - 只需要一些细节(即集合和 id)。所有字段都假定为列(如果类已映射)。如果没有集合,这样就足够了:
<?xml version="1.0" encoding="UTF-8" ?>
<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
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
<description>External entities from library X</description>
<package>com.external.library</package>
<entity class="SomeClassName">
<id>..</id>
</entity>
<entity class="AnotherClassName">
<id>..</id>
</entity>
</entity-mapping>
Run Code Online (Sandbox Code Playgroud)
请注意,指定时<package>不需要完全限定的名称。
如果您想要一个名称与 不同的文件orm.xml,请persistence.xml通过以下方式指定:
<mapping-file>customMappingFile.xml</mapping-file>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2111 次 |
| 最近记录: |