一對多:mybatis
mybatis中一對多查詢可使用collection標籤。有兩種使用方法:ci
一種是:使用關聯查詢io
<collection>泛型
<result column="CreateTime" />List
</collection>select
查詢的語句中使用關聯查詢命名空間
第二種是:<collection property="maintainrecDetailList" ofType="***.Maintainrecdetail" select="queryDetail" column="recNumber"/>sso
property:實體類中屬性名,ofType:泛型的實體類的位置,select:命名空間+方法名,column:外鍵列名(不用區分大小寫問題)引用
一對一:方法
一種是:使用關聯查詢
<association property="createComBr" >
<result column="CreateTime" />
</association>
查詢的語句中使用關聯查詢
第二種:引用外部查詢語句
<association property="createComBr" column="CreateComBrID" select="***.dao.CompanyBranchDao.findCompanyBranchByComBr" >
</association>
property:實體類中屬性名,select:命名空間+方法名,column:外鍵列名(不用區分大小寫問題)