Mybatis 多表关联 查询条件是重复字段,Mapping.xml如何解决?
现在有2张表,一个 广告表(cnt_advert),一个广告位置表(cnt_advert_location)
我建立了2个bean
public class Advert
private String id;
private String name;
private String accountType;
private String url;
private String picUrl;
private String createTime;
private String startTime;
private String endTime;
private String remark;
private Integer sort;
private String isEnable; // get/set 方法省略
public class AdLocation
private String id;
private String code;
private String name;
private String size;
private Integer num;
private String createTime;
private String isEnable; // get/set 方法省略
映射文件是:
<mapper namespace="com.advert.dao.AdvertDao">
<resultMap id="BaseResultMap" type="com.advert.bean.Advert">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="account_type" property="accountType" />
<result column="url" property="url" />
<result column="pic_url" property="picUrl" />
<result column="create_time" property="createTime" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="remark" property="remark" />
<result column="sort" property="sort" />
<result column="is_enable" property="isEnable" />
</resultMap>
<select id="selectPageList" resultMap="BaseResultMap"
parameterType="com.advert.bean.Advert">
select a.name,b.name as location_name
from cnt_advert a ,cnt_advert_location b
where a.location_id=b.id
and b.name='1a'
</select>
求大神赐教,谢谢