publicinterfaceCountryDao{
Country selectCountryById(Integer cid);}
定义配置文件
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="com.yajun.mybaits.one2many.dao.CountryDao"><selectid="selectMinisterByCid"resultType="Minister">
select mid,mname from minister where countryId=#{ooo}
</select><resultMapid="countryMapper"type="Country"><idcolumn="cid"property="cid"/><resultcolumn="cname"property="cname"/><collectionproperty="ministers"select="selectMinisterByCid"column="cid"></collection></resultMap><selectid="selectCountryById"resultMap="countryMapper">
select cid,cname from country where cid=#{cid}
</select></mapper>
测试类
@Testpublicvoidtest01(){
Country country = countryDao.selectCountryById(1);
System.out.println(country);}}```
## 多对一关联查询
## 自关联查询
## 多对多关联查询