读书人

ibatis3 联系关系查询lt;association/

发布时间: 2012-10-24 14:15:58 作者: rapoo

ibatis3 关联查询,<association/> coumn添加多列条件

<resultMap type="themeFormatBean" id="themeFormatMap"><id column="THFORMAT_ID" property="thFormatId"  /><result column="THTYPE_TH_ID" property="thId"  /><result column="THTYPE_HEIGHT" property="thHeight"  /><result column="THTYPE_WIDTH" property="thWidth"  /><result column="TH_BG_ID" property="thBgId"  /><result column="THTYPE_RSPACE" property="thRSpace"  /><result column="THTYPE_CSPACE" property="thCSpace"  /><result column="THTYPE_TXT_HEIGHT" property="thTxtHeight"  javaType="int" jdbcType="INTEGER" /><result column="THTYPE_TXT_WIDTH" property="thTxtWidth"  javaType="int" jdbcType="INTEGER"/><result column="THTYPE_TXT_X" property="thTxtX"  /><result column="THTYPE_TXT_Y" property="thTxtY"  /><!--<result column="TH_URL" property="thUrl"  />--><result column="TH_FONTID" property="thFontId"  /><result column="TH_FONTSIZE" property="thFontSize"  /><result column="TH_FONTCOLOR" property="thFontColor"  /><result column="TH_ISDEFAULT" property="thIsDefault"/><association property="thUrl" column="{themeIndex=TH_BG_ID,width=THTYPE_WIDTH,height=THTYPE_HEIGHT}"  select="getUrlByBgId"></association></resultMap>
<select id="getUrlByBgId" parameterType="com.contentlib.beans.bussiness.ThemeByIndex" resultType="String">??SELECT MATERIAL_URL FROM ctt_material_standard? WHERE MATERIAL_ID = #{themeIndex} ???and MATERIAL_WIDTH=#{width} and MATERIAL_HEIGHT=#{height}?</select>

?<association property="thUrl" column="{themeIndex=TH_BG_ID,width=THTYPE_WIDTH,height=THTYPE_HEIGHT}"
select="getUrlByBgId"></association>
colum 通过{}添加多列条件查询

在select语句中解析传入sql语句,在网上找了一下,自己摸索了一下,发现居然可以这样子用。。。

java类:

public class ThemeByIndex {private String themeIndex;private int width;private int height;public String getThemeIndex() {return themeIndex;}public void setThemeIndex(String themeIndex) {this.themeIndex = themeIndex;}public int getWidth() {return width;}public void setWidth(int width) {this.width = width;}public int getHeight() {return height;}public void setHeight(int height) {this.height = height;}}

?

读书人网 >软件架构设计

热点推荐