Hibernate 다 중 맵

예전 에 하 이 버 네 이 트 많이 배 울 때 쓴 코드 예요!여기에 두 가지 서로 다른 방식 의 다 중 맵 을 소개 합 니 다!예 를 들 어 Emplore 와 Project 를 목표 로 합 니 다!설정
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.softceo.hibernate.dto.Project" table="PROJECT" schema="SCOTT">
        <id name="proid" type="java.lang.Integer">
            <column name="PROID" precision="22" scale="0" />
            <generator class="assigned" />
        </id>
        <property name="proname" type="java.lang.String">
            <column name="PRONAME" length="20" not-null="true" />
        </property>
        <property name="prodescription" type="java.lang.String">
            <column name="PRODESCRIPTION" length="200" not-null="true" />
        </property>
        <set name="emplorees" table="R_TMP_PROJ" schema="SCOTT" cascade="save-update">
            <key>
                <column name="R_PROJ_ID" precision="22" scale="0" not-null="true" />
            </key>
            <many-to-many entity-name="com.softceo.hibernate.dto.Emploree">
                <column name="R_EMP_ID" precision="22" scale="0" not-null="true" />
            </many-to-many>
        </set>
    </class>
</hibernate-mapping>

다른 설정 은:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.softceo.hibernate.dto.Project" table="PROJECT" schema="SCOTT">
        <id name="proid" type="java.math.BigDecimal">
            <column name="PROID" precision="22" scale="0" />
            <generator class="assigned" />
        </id>
        <property name="proname" type="java.lang.String">
            <column name="PRONAME" length="20" not-null="true" />
        </property>
        <property name="prodescription" type="java.lang.String">
            <column name="PRODESCRIPTION" length="200" not-null="true" />
        </property>
        <set name="RTmpProjs" inverse="true" cascade="save-update">
            <key>
                <column name="R_PROJ_ID" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.softceo.hibernate.dto.RTmpProj" />
        </set>
    </class>
</hibernate-mapping>

이 설정 은 새로운 실체 맵 을 추가 한 것 입 니 다.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.softceo.hibernate.dto.RTmpProj" table="R_TMP_PROJ" schema="SCOTT">
        <composite-id>
            <key-many-to-one name="emploree" class="com.softceo.hibernate.dto.Emploree">
                <column name="R_EMP_ID" precision="22" scale="0" />
            </key-many-to-one>
            <key-many-to-one name="project" class="com.softceo.hibernate.dto.Project">
                <column name="R_PROJ_ID" precision="22" scale="0" />
            </key-many-to-one>
        </composite-id>
    </class>
</hibernate-mapping>

구체 적 인 코드 는 첨부 파일 참조!

좋은 웹페이지 즐겨찾기