使用 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>