사용자 도구

사이트 도구


java:jpa:xml_config

JPA XML Configuration

기본 orm.xml 뼈대

<?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>
java/jpa/xml_config.txt · 마지막으로 수정됨: 2015/08/25 17:47 저자 kwon37xi