一对一级联查询映射文件PersonMapper.xml代码:
/p>
PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select* from person where id=#{id}
select p.*,ic.code
from person p,idcard ic
where p.idcard_id= ic.id and p.id=#{id}
select p.*,ic.code
from person p,idcard ic
where p.idcard_id= ic.id and p.id=#{id}
IdCardMapper.xml代码:
/p>
PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select* from idcard where id =#{id}
一对多查询映射文件OrdersMapper.xml代码:
/p>
PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select* from orders where user_id =#{id}
UserMapper.XML代码:
/p>
PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select* from user where uid =#{id}
select u.*,o.id,o.ordersn
from user u,orders o
where u.uid= o.user_id and u.uid=#{id}
select u.*,o.id,o.ordersn
from user u,orders o
where u.uid= o.user_id and u.uid=#{id}
多对多查询,映射文件OrdersMapper.xml文件
/p>
PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select* from user where uid =#{id}
select u.*,o.id,o.ordersn
from user u,orders o
where u.uid= o.user_id and u.uid=#{id}
select u.*,o.id,o.ordersn
from user u,orders o
where u.uid= o.user_id and u.uid=#{id}