entity
public class BsEnterpriseFinanceYear extends Model<BsEnterpriseFinanceYear> {
private BsEnterprise bsEnterprise;//另一个类对象
}
Mapper
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.fastfinger.dev.bsEnterpriseFinanceYear.entity.BsEnterpriseFinanceYear">
<id column="finance_id" property="financeId"/>
<result column="ent_id" property="entId"/>
<association property="bsEnterprise" javaType="com.fastfinger.dev.bsEnterprise.entity.BsEnterprise">
<result column="ent_name" property="entName"/>
</association>
</resultMap>
<if test="entity.bsEnterprise.entName != '' and entity.bsEnterprise.entName != null">
and e.ent_name like concat('%',#{entity.bsEnterprise.ent_name},'%')
</if>
注意: 被嵌套对象如果有被查询条件,需在前面new个对象并赋给 对象,否则需要在判断条件前增加判断对象是否为空
例:
<if test=" entity.bsEnterprise != null">
<if test="entity.bsEnterprise.entName != '' and entity.bsEnterprise.entName != null">
and e.ent_name like concat('%',#{entity.bsEnterprise.entName},'%')
</if>
</if>