在BeanA中引用BeanB对象
public class A{
private String userId;
private B b;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId= userId;
}
public B getB() {
return b;
}
public void setA(B b) {
this.b= b;
}
}
public class B{
private String userId;
private String name;
private String tel;
.....set \get方法
}
A_SqlMap.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="A" >
<resultMap id="ibatorgenerated_BaseResultMap" class="portalcore.dao.vo.TUsers" >
<!--
WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
-->
<result column="A" property="userId" jdbcType="VARCHAR" />
<result property="b" column="USER_ID"
select="b.selectById" />
</resultMap>
省略
</sqlMap>
B_SqlMap.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="T_TERMINAL" >
<resultMap id="ibatorgenerated_BaseResultMap" class="portalcore.dao.vo.TTerminal" >
<!--
WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
-->
<result column="USER_ID" property="userId" jdbcType="VARCHAR" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="TEL" property="tel" jdbcType="VARCHAR" />
</resultMap>
<!--自己定义的-->
<select id="selectById" resultMap="ibatorgenerated_BaseResultMap" parameterClass="String" >
<!--
WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
-->
select USER_ID,NAME,TEL
from B where USER_ID=#userId:VARCHAR#
</select>
</sqlMap>
在查询A 的同时也查询了B