toSQL
Mybatis XML 转换为 SQL语句
源码地址: https://github.com/huxuekuo/toSQL
使用方法
- 可以在IDEA plugin 中搜索 toSQL
- 使用源码编译后的jar, 在IDEA plugin 中添加
- 在releases中下载jar文件
转换效果展示
<select id="findPage" parameterType="map" resultMap="BaseResultMap">
select * from c AS c
<where>
and deleted = '0'
<if test="name!=null">
and c.name LIKE CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
</if>
<if test="pageStatus!=null">
and c.page_status = #{pageStatus,jdbcType=INTEGER}
</if>
<if test="startTime != null and startTime!=''">
and c.start_time >= #{startTime}
</if>
<if test="endTime != null and endTime!='' ">
and c.end_time <= #{endTime}
</if>
</where>
ORDER BY c.add_time desc,c.update_time desc
</select>
转换后
SELECT
*
FROM
dts_component_page c
WHERE
deleted = '0'
AND deleted = '0'
AND c.NAME LIKE concat( '%', '', '%' )
AND c.page_status = ''
AND c.start_time >= ''
AND c.end_time <= ''
ORDER BY
c.add_time DESC,
c.update_time DESC