사용자 도구

사이트 도구


java:jpa:persistence.xml

문서의 이전 판입니다!


JPA persistence.xml

  • META-INF/persistence.xml 위치 고정이다.
  • 위치와 파일명을 변경하고자 한다면 스스로 XML 파일로부터 PersistenceUnitInfo 인스턴스를 생성하여 넘기는 방법만 있는 듯 하다. Spring이 이렇게 처리하는 듯.
  • 기본 뼈대
    <?xml version="1.0" encoding="utf-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
        version="2.0">
        <persistence-unit name="unitname" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <exclude-unlisted-classes>true</exclude-unlisted-classes>
            <mapping-file>ormap.xml</mapping-file>
            <class>org.acme.Employee</class>
            <class>org.acme.Person</class>
            <class>org.acme.Address</class>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            </properties>
        </persistence-unit>
    </persistence>
  • exclude-unlisted-classestrue로 하면 <class>xx</class>로 명시한 클래스만 엔티티로 로딩한다. false이면 CLASSPATH에서 자동 탐색한다.
java/jpa/persistence.xml.1412162657.txt.gz · 마지막으로 수정됨: 2014/10/01 20:24 저자 kwon37xi