在mybatis-plus中做一个连表的查询,我返回的结果集仅仅是一个实体类,就是type中映射的MixRecordDetails。
mybatis-plus中查询。返回结果集只写resultMap标签对,没result标签对也能返回成为这个实体类?
但是我不懂,难道可以不写结果集吗?
<resultMap id="MixRecord" type="com.MixRecordDetails">
//这里的result删除后依旧可以运行和返回结果为MixRecordDetails
<result column="name" property="name"></result>
<result column="id_card" property="id_card"></result>
<result column="telphone" property="telphone"></result>
<result column="status" property="status" ></result>
<result column="dept" property="dept"></result>
<result column="batch" property="batch"></result>
<result column="num" property="num"></result>
<result column="begin_time" property="begin_time"></result>
<result column="end_time" property="end_time"></result>
</resultMap>
<select id="search" resultMap="MixRecord">
select a.name,a.id_card,a.telphone,a.dept,a.status,a.batch,a.num,b.begin_time,b.end_time FROM mixrecord a JOIN mix_record_batch b ON a.batch = b.batch
<where>
<if test="mixrecord.name != null and mixrecord.name != ''">
and a.name LIKE CONCAT('%',#{mixrecord.name},'%' )
</if>
<if test="mixrecord.id_card != null and mixrecord.id_card != ''">
and a.id_card = #{mixrecord.id_card}
</if>
<if test="mixrecord.telphone != null and mixrecord.telphone != ''">
and a.telphone = #{mixrecord.telphone}
</if>
<if test="mixrecord.dept != null and mixrecord.dept != ''">
and a.dept LIKE CONCAT('%',#{mixrecord.dept},'%' )
</if>
<if test="mixrecord.batch != null and mixrecord.batch != ''">
and a.batch LIKE CONCAT('%',#{mixrecord.batch},'%' )
</if>
<if test="mixrecord.status != null and mixrecord.status != ''">
and a.batch = #{mixrecord.status}
</if>
<if test="mixrecord.batchId != null and mixrecord.batchId != ''">
and b.id = #{mixrecord.batchId}
</if>
</where>
</select>