many-to-one和one-to-many的配置比较

时间:2021-11-04 16:23:00

many-to-one配置:

<many-to-one name="dailyCatalog" column="daily_catalog_id" class="com.tyloo.po.DailyCatalog"  fetch="join" lazy="false" />

one-to-many配置:

<set name="company" fetch="join" lazy="false"> 
        
            <key column="company_id"></key>
            <!--
                这里的column="company_id" 是指明了在company_data表里有一个company_id的列名,是指向company_data表的外键
            -->
            <one-to-many class="com.tyloo.po.CompanyData" />
</set>