Mybatis Dynamic SQL

1. If <select id="findActiveBlogWithTitleLike" resultType="Blog"> SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <if test="title != null"> AND title like #{title} </if> </select> 2. Choose, When, Otherwise <select id="findActiveBlogLike" resultType="Blog"> SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <choose> # choose only one case among many options <when test="title != Read more

Mybatis foreach tag

Six Attributes collection: There are three formats: list, array, and map, according to the type of parameter passed. item: the parameter name of the set of objects in the tag. separator: the separator at the end of each sub-loop, usually “,”. open: start character, often “(“. close: end character, often Read more