mybatis 返回 list<object>

来源:互联网 发布:紫鸟数据魔方怎么使用 编辑:程序博客网 时间:2024/05/23 16:33

 使用  resultMap  

使用了 springmvc的SqlSessionTemplate


interface  接口

public  List<Design> findDesignByOpenId(String openid) throws Exception;

impl  实现 调用

public List<Design> findDesignByOpenId(String openid) throws Exception {
return  (List<Design>) dao.findForList("com.jy.entity.system.DesignList.findDesignListByOpenId", openid);
}


mapper.xml


定义返回类型 

<resultMap type="Design"  id="designResultMap">
<id column="design_id" property="design_id"/>
<result column="idCreator" property="idCreator"/>
<result column="showPicture" property="showPicture"/>
<result column="showText" property="showText"/>
<result column="releaseTime" property="releaseTime"/>
<result column="endTime" property="endTime"/>
<result column="endHand" property="endHand"/>
<result column="isDelete" property="isDelete"/>
<result column="title" property="title"/>
<result column="field" property="field"/>
</resultMap>


查询语句

<select id="findDesignListByOpenId"   parameterType="String"   resultMap="designResultMap">
select   
design_id, idCreator, showPicture, showText, releaseTime, endTime, endHand, isDelete, title, field
from
 form_design
where
   idCreator = #{openid}
</select>


原创粉丝点击