直接上代码:
两个映射配置文件: Customer.xml 和 Address.xml Customer.xml
<mapper namespace="com.liyan.mybatis.po.Customer">
<resultMap type="com.liyan.mybatis.po.Customer" id="customerResult">
<id property="id" column="id" javaType="int" jdbcType="INTEGER"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<association property="address" column="id_address" select="selectAddress" >
</association>
</resultMap> <select id="selectCustomer" parameterType="String" resultMap="customerResult" >
select * from customer as c left join
Address as a on c.id_address=a.id
where c.name=#{name}
</select>Address.xml <mapper namespace="com.liyan.mybatis.po.Address">
<resultMap type="com.liyan.mybatis.po.Address" id="addressResult">
<id property="id" column="id" javaType="int" jdbcType="INTEGER"/>
<result property="stress" column="stress" javaType="String" jdbcType="VARCHAR"/>
<result property="city" column="city" javaType="String" jdbcType="VARCHAR"/>
</resultMap>
</mapper>现在我的PO类都已经写好了,映射的对象也有了有了 可就是抛 Mapped Statements collection does not contain value for com.liyan.mybatis.po.Customer.selectAddress
怎么解决啊... 第一次用Mybatis 小弟不太明白 resultMap到底是干什么的...
两个映射配置文件: Customer.xml 和 Address.xml Customer.xml
<mapper namespace="com.liyan.mybatis.po.Customer">
<resultMap type="com.liyan.mybatis.po.Customer" id="customerResult">
<id property="id" column="id" javaType="int" jdbcType="INTEGER"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<association property="address" column="id_address" select="selectAddress" >
</association>
</resultMap> <select id="selectCustomer" parameterType="String" resultMap="customerResult" >
select * from customer as c left join
Address as a on c.id_address=a.id
where c.name=#{name}
</select>Address.xml <mapper namespace="com.liyan.mybatis.po.Address">
<resultMap type="com.liyan.mybatis.po.Address" id="addressResult">
<id property="id" column="id" javaType="int" jdbcType="INTEGER"/>
<result property="stress" column="stress" javaType="String" jdbcType="VARCHAR"/>
<result property="city" column="city" javaType="String" jdbcType="VARCHAR"/>
</resultMap>
</mapper>现在我的PO类都已经写好了,映射的对象也有了有了 可就是抛 Mapped Statements collection does not contain value for com.liyan.mybatis.po.Customer.selectAddress
怎么解决啊... 第一次用Mybatis 小弟不太明白 resultMap到底是干什么的...
解决方案 »
- 各位大虾,帮忙解决setInterval问题吧~~急!!
- strusts2的问题。。
- 关于flex,如何将java端返回的arraylist类型绑定到flex tree组件的dataProvider上?
- struts中的logic:iterate 如何显示出数据库中的BLOB类型的图片
- 200分跪求struts-faces.jar包~~~~~
- 请问jstl能否格式化显示Calendar型的日期?应该怎么做?急................
- 为什么我的消息驱动Bean从Weblogic的queue中读取不到数据?????急急!!!!!!!!!1111
- 在SOcket建立连接后,客户端怎么样才知道服务器端发送过来数据??
- hibernate org.apache.jasper.JasperException: could not find file: hibernate.cfg.xml
- 在tomcat5.0下关于JDBC连接mysql的讨论
- 求助SSH一个空指针问题 请大家帮忙解决一下下
- 正则,筛选图片地址
<resultMap type="com.liyan.mybatis.po.Customer" id="customerResult">
<id property="id" column="id" javaType="int" jdbcType="INTEGER"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<association property="address" column="id_address" resultMap="addressResult" >
</association>
</resultMap> <select id="selectCustomer" parameterType="String" resultMap="customerResult" >
select * from customer as c left join
Address as a on c.id_address=a.id
where c.name=#{name}
</select></mapper>