在springboot中利用mybatis实现动态查询出现了错误
syntax error, expect ')'
源码
<insert id="insertEmploy" parameterType="com.example.springboot06mybatis.bean.Employee">insert into employee<trim prefix="(" suffixOverrides="," suffix=")"><if test="emp_lastName != null">lastName,</if><if test="email != null">email,</if><if test="gender != null">gender,</if><if test="dId != null">d_id,</if></trim><trim prefix="values=(" suffixOverrides="," suffix=")"><if test="emp_lastName != null">#{emp_lastName},</if><if test="email != null">#{email},</if><if test="gender != null">#{gender},</if><if test="dId != null">#{dId},</if></trim></insert>
之所以会出现错误,是因为下面这行语句写出了"values=("
<trim prefix="values=(" suffixOverrides="," suffix=")">
只需要将上面修改为如下便可
<trim prefix="values(" suffixOverrides="," suffix=")">