mybatis中三表联查 ゞ 浴缸里的玫瑰 2023-10-05 19:01 1阅读 0赞 要求: 1、查询模型信息(存放于模型表 DT\_MODEL) 2、所在域(存放于集值表 DATA\_SET) 3、状态(存放于集值表 DATA\_SET) ![sql分析][sql] 完整sql <select id="getDtModelPage" parameterType="com.ats.dt.entity.vo.MapperPage" resultMap="BaseResultMapWithRealation"> select * FROM (SELECT A.*, ROWNUM RN FROM (SELECT dt.*, ds.data_set_meaning as domainIdName, dss.data_set_meaning as statusName FROM DT_MODEL dt left join DATA_SET ds on dt.DOMAIN_ID = ds.DATA_SET_SOID left join DATA_SET dss on dt.status = dss.DATA_SET_SOID WHERE 1=1 and dt.IS_DELETE = 0 <if test="search!=null"> and ( MODEL_ENG_NAME like '%${search}%' or MODEL_CHI_NAME like '%${search}%' or PY_CODE like '%${search}%' or WB_CODE like '%${search}%' ) </if> ORDER BY dt.CREATE_DATE DESC) A ) WHERE RN BETWEEN #{pageSt} AND #{pageEd} </select> ![属性映射][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzgxMTA1Nw_size_16_color_FFFFFF_t_70] 完整属性 <mapper namespace="com.ats.dt.Mapper.DtModelMapper"> <resultMap id="BaseResultMap" type="com.ats.dt.entity.DtModel"> <id column="SOID" property="soid" jdbcType="DECIMAL"/> <result column="DOMAIN_ID" property="domainId" jdbcType="DECIMAL"/> <result column="MODEL_ENG_NAME" property="modelEngName" jdbcType="VARCHAR"/> <result column="MODEL_CHI_NAME" property="modelChiName" jdbcType="VARCHAR"/> <result column="PY_CODE" property="pyCode" jdbcType="VARCHAR"/> <result column="WB_CODE" property="wbCode" jdbcType="VARCHAR"/> <result column="STATUS" property="status" jdbcType="DECIMAL"/> <result column="VERSION" property="version" jdbcType="DECIMAL"/> <result column="DEFINITION" property="definition" jdbcType="VARCHAR"/> <result column="PUBLISH_DATE" property="publishDate" jdbcType="TIMESTAMP"/> <result column="IS_DELETE" property="isDelete" jdbcType="DECIMAL"/> <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP"/> <result column="UPDATE_DATE" property="updateDate" jdbcType="TIMESTAMP"/> <result column="UPDATE_USER" property="updateUser" jdbcType="DECIMAL"/> </resultMap> <resultMap id="BaseResultMapWithRealation" type="com.ats.dt.entity.vo.DtModelPageVo" extends="BaseResultMap"> <result column="domainIdName" jdbcType="VARCHAR" property="domainIdName"/> <result column="statusName" jdbcType="VARCHAR" property="statusName"/> </resultMap> 3、实体类 DtModelPageVo /** * 数据模型 */ @Setter @Getter public class DtModelPageVo extends DtModel implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "所在域", required = false) private Long domainIdName; @ApiModelProperty(value = "状态", required = false) private String statusName; } DtModel @Setter @Getter public class DtModel implements Serializable { private Long soid; private Long domainId; private String modelEngName; private String modelChiName; private String pyCode; private String wbCode; private Long status; private Long version; private String definition; @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") private Date publishDate; private Long isDelete; private Date createDate; private Date updateDate; private Long updateUser; private static final long serialVersionUID = 1L; } [sql]: https://img-blog.csdnimg.cn/20210202214718669.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzgxMTA1Nw==,size_16,color_FFFFFF,t_70 [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzgxMTA1Nw_size_16_color_FFFFFF_t_70]: https://img-blog.csdnimg.cn/20210202215140500.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzgxMTA1Nw==,size_16,color_FFFFFF,t_70
还没有评论,来说两句吧...