当前位置: 代码迷 >> 综合 >> Springboot中配置动态sql查询出现的错误syntax error, expect ‘)‘
  详细解决方案

Springboot中配置动态sql查询出现的错误syntax error, expect ‘)‘

热度:44   发布时间:2024-02-26 10:28:54.0

在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=")">
  相关解决方案