0

こんにちは、多対多の関係で休止状態に問題があります。多対多のテーブルが 2 つあるので、2 つのテーブル間の関係を保持するテーブルをもう 1 つ導入しました。私の構成(hbm)ファイルでは、親テーブルを照会するたびに親と子の両方の情報を取得したいので、lazy="false" と fetch="join" を作成しました。両方のテーブル間の関係を保持します)。しかし、私は両親の情報を取得できません。以下の例外が発生しています。

構成スニペット

Parent 1 - 
    <hibernate-mapping>
        <class name="com.sample.Technology" table="TECHNOLOGY">
            <id name="technologyId" type="big_decimal">
                <column name="TECHNOLOGY_ID" precision="22" scale="0" />
                <generator class="increment" />
            </id>
            <property name="technologyName" type="string">
                <column name="TECHNOLOGY_NAME" length="50" not-null="true" unique="true" />
            </property>
            <property name="technologyDesc" type="string">
                <column name="TECHNOLOGY_DESC" length="500" />
            </property>
            <set name="regionTechnologyCapabilities" table="REGION_TECHNOLOGY_CAPABILITY" cascade="all" inverse="true" lazy = "false" fetch="join">
                <key>
                    <column name="TECHNOLOGY_ID" precision="22" scale="0" not-null="true" unique="true" />
                </key>
                <one-to-many class="com.sample.RegionTechnologyCapability" />
            </set>
        </class>
    </hibernate-mapping>
Parent 2 : -

<class name="com.sample.Region" table="REGION">
    <id name="regionId" type="big_decimal">
        <column name="REGION_ID" precision="22" scale="0" />
        <generator class="increment" />
    </id>
    <property name="regionName" type="string">
        <column name="REGION_NAME" length="50" not-null="true" unique="true" />
    </property>
    <property name="regionDesc" type="string">
        <column name="REGION_DESC" length="500" />
    </property>
    <set name="regionTechnologyCapabilities" table="REGION_TECHNOLOGY_CAPABILITY" cascade="all" inverse="true" lazy = "false" fetch="join">
        <key>
            <column name="REGION_ID" precision="22" scale="0" not-null="true" unique="true" />
        </key>
        <one-to-many class="com.sample.RegionTechnologyCapability" />
    </set>
</class>

Relational Table 3 :-    <class name="com.sample.RegionTechnologyCapability" table="REGION_TECHNOLOGY_CAPABILITY">
        <id name="regionTechCapbId" type="big_decimal">
            <column name="REGION_TECH_CAPB_ID" precision="22" scale="0" />
            <generator class="increment" />
        </id>
        <many-to-one name="region" class="com.sample.Region" fetch="join">
            <column name="REGION_ID" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="technology" class="com.sample.Technology" fetch="join">
            <column name="TECHNOLOGY_ID" precision="22" scale="0" not-null="true" />
        </many-to-one>
    </class>
4

1 に答える 1

0

なぜ手動で結合テーブルをマップするのですか?双方向の多対多を使用して、Hibernateに結合テーブルを処理させます!

<hibernate-mapping>
    <class name="com.sample.Technology" table="TECHNOLOGY">
        <id name="technologyId" type="big_decimal" column="TECHNOLOGY_ID">
            <generator class="increment"/>
        </id>
        <set name="regions" table="REGION_TECHNOLOGY" inverse="true">
            <key column="TECHNOLOGY_ID"/>
            <many-to-many column="REGION_ID" class="com.sample.Region"/>
        </set>
    </class>
</hibernate-mapping>

<hibernate-mapping>
    <class name="com.sample.Region" table="REGION">
        <id name="regionId" type="big_decimal" column="REGION_ID">
            <generator class="increment"/>
        </id>
        <set name="technologies" table="REGION_TECHNOLOGY">
            <key column="REGION_ID"/>
            <many-to-many column="TECHNOLOGY_ID" class="com.sample.Technology"/>
        </set>
    </class>
</hibernate-mapping>
于 2013-03-14T16:48:37.963 に答える