orm.xml
) 엔티티를 설정하는 것도 가능하다.META-INF/orm.xml
이며, 이 경우에는 자동으로 읽는다.<mapping-file>package/to/orm.xml</mapping-file>
형태로 기술한다.<?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_2_0.xsd" version="2.0"> <!-- Global Meta data 없어도 무관. 단 한번만. --> <persistence-unit-metadata> <xml-mapping-metadata-complete/> <persistence-unit-defaults> <schema>myschema</schema> <catalog>mycatalog</catalog> <cascade-persist/> </persistence-unit-defaults> </persistence-unit-metadata> <!-- 엔티티 매핑 Override --> <package>org.hibernate.test.annotations.reflection</package> <entity class="Administration" access="PROPERTY" metadata-complete="true"> <table name="tbl_admin"> <unique-constraint> <column-name>firstname</column-name> <column-name>lastname</column-name> </unique-constraint> </table> <secondary-table name="admin2"> <primary-key-join-column name="admin_id" referenced-column-name="id"/> <unique-constraint> <column-name>address</column-name> </unique-constraint> </secondary-table> <id-class class="SocialSecurityNumber"/> <inheritance strategy="JOINED"/> <sequence-generator name="seqhilo" sequence-name="seqhilo"/> <table-generator name="table" table="tablehilo"/> ... </entity> <entity class="PostalAdministration"> <table name="Account" /> <named-native-query name="myQuery" result-set-mapping="nicknames"> <query><![CDATA[ select a.nickname from Account a ]]></query> </named-native-query> <sql-result-set-mapping name="nicknames"> <column-result name="nickname" /> </sql-result-set-mapping> <primary-key-join-column name="id"/> </entity> </entity-mappings>