用户登录
用户注册

分享至

hibernate 多对多 fetch

  • 作者: 婊酱
  • 来源: 51数据库
  • 2020-11-05

以下配置只针对多对多关系中的字段,别的不需要写,你应该会

类三的private Long qgServiceCategory_id;改为对象吧


实体类一的映射文件

<set name="serviceCategorys" inverse="true">

            <key>

                <column name="id" precision="10" scale="0" not-null="true" />

            </key>

            <one-to-many class="类三" />

        </set>

实体类二

<set name="qgOffices" inverse="true">

            <key>

                <column name="id" precision="10" scale="0" not-null="true" />

            </key>

            <one-to-many class="类三" />

        </set>

实体类三

<many-to-one name="office" class="office的类" fetch="select">

            <column name="表三id或id2" precision="10" scale="0" not-null="true" />

        </many-to-one>

        <many-to-one name="qgServiceCategory" class="oqgServiceCategory对应的类" fetch="select">

            <column name="表三id或id2" precision="10" scale="0" not-null="true" />

        </many-to-one>

因为你的表述不太清楚所以只能给个模型,按这样改就行了


软件
前端设计
程序设计
Java相关