prefix : 給<trim>包裹的sql語句加上前綴.sql
suffix : 給<trim>包裹的sql語句加上後綴.api
prefixOverrides: 若是<trim>包裹的sql語句是空語句(常常出如今 if 判斷爲否的狀況下),取消指定的前綴,如where.ide
suffixOverrides: 若是<trim>包裹的sql語句是空語句(常常出如今 if 判斷爲否的狀況下),取消指定的後綴,如and | or. 逗號等ui
<!-- 新增--><insert id="save" parameterType="com.yp.api.qa.model.QuestionTemplate" keyProperty="id"> insert into yp_qa.q_question_template <trim prefix="(" suffix=")" suffixOverrides="," > <if test="cateid != null"> cateid, </if> <if test="title != null"> title, </if> <if test="author != null"> author, </if> <if test="type != null"> type, </if> <if test="img != null"> img, </if> <if test="video != null"> video, </if> <if test="music != null"> music, </if> <if test="hydesc != null"> hydesc, </if> <if test="uid != null"> uid, </if> createtime, <if test="tags != null"> tags, </if> <if test="accountid != null"> accountid, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="cateid != null"> #{cateid}, </if> <if test="title != null"> #{title}, </if> <if test="author != null"> #{author}, </if> <if test="type != null"> #{type}, </if> <if test="img != null"> #{img}, </if> <if test="video != null"> #{video}, </if> <if test="music != null"> #{music}, </if> <if test="hydesc != null"> #{hydesc}, </if> <if test="uid != null"> #{uid}, </if> now(), <if test="tags != null"> #{tags}, </if> <if test="accountid != null"> #{accountid}, </if> </trim></insert>