嗨,我有一个涉及多对多关系的休眠问题。我有两张多对多的表,所以我又介绍了一张保存两张表之间关系的表。在我的配置(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>