一对多:
mybatis中一对多查询可以使用collection标签。有两种使用方法:
一种是:使用关联查询
<collection>
<result column="CreateTime" />
</collection>
查询的语句中使用关联查询
第二种是:<collection property="maintainrecDetailList" ofType="***.Maintainrecdetail" select="queryDetail" column="recNumber"/>
property:实体类中属性名,ofType:泛型的实体类的位置,select:命名空间+方法名,column:外键列名(不用区分大小写问题)
一对一:
一种是:使用关联查询
<association property="createComBr" >
<result column="CreateTime" />
</association>
查询的语句中使用关联查询
第二种:引用外部查询语句
<association property="createComBr" column="CreateComBrID" select="***.dao.CompanyBranchDao.findCompanyBranchByComBr" >
</association>
property:实体类中属性名,select:命名空间+方法名,column:外键列名(不用区分大小写问题)