Suppose I am executing below query which is there in my mapper xml:
<select id="getData" parameterType="java.util.HashMap" resultType="java.util.LinkedHashMap">
select * from emp where empId=#{empId}
</select>
In the above xml empId is the dynamic value that returns the value from the key of the HashMap that is passed as parameter in above mapper xml in Mybatis.
Is there any way to print the sql with the passed param to the console when the above select query mapped to method getData is ran.
for example I pass data empId =1 I want in console : select * from emp where empId=1
add log4j.properties
log4j.logger.yourmapperpackage=DEBUG
and the sql debug is like this:
2016-01-09 20:51:10,621 DEBUG [com.xxxMapper.insert] - <==> Preparing: INSERT INTO video_info (content, id, create_time, title, media_url, zhan_count, cover_url) VALUES (?, ?, ?, ?, ?, ?, ?) >
2016-01-09 20:51:10,627 DEBUG [com.xxxMapper.insert] - <==> Parameters: vcontent(String), 0(Long), 2016-01-09 20:51:10.616(Timestamp), vtitle(String), null, 1(Integer), null>
2016-01-09 20:51:10,628 DEBUG [com.xxxMapper.insert] - <<== Updates: 1>