Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 更新数据库时出错!表或视图不存在_Jquery_Database_Mybatis - Fatal编程技术网

Jquery 更新数据库时出错!表或视图不存在

Jquery 更新数据库时出错!表或视图不存在,jquery,database,mybatis,Jquery,Database,Mybatis,我有这个疑问 <update id="updateRow"> update ROW set DISPLAY_ID = #{displayId} <where> <include refid="rowCriteria" /> </where> </update> <sql id="rowCriteria"> <if test="criteria.

我有这个疑问

<update id="updateRow">
    update
      ROW
    set
      DISPLAY_ID = #{displayId}
    <where>
      <include refid="rowCriteria" />
    </where>
</update>

 <sql id="rowCriteria">
  <if test="criteria.displayId} != null">
     DISPLAY_ID=#{criteria.displayId}
  </if>
  <if test="criteria.id != null">
    and ID=#{criteria.id}
  </if>
 </sql>
我得到这个错误

该错误可能涉及defaultParameterMap 设置参数时出错 SQL:更新行集显示\u ID=?其中ID=? 原因:java.sql.SQLSyntaxErrorException:ORA-00942:表或视图不存在 但如果我从标准ID中删除“and”

 <sql id="rowCriteria">
  <if test="criteria.displayId} != null">
    DISPLAY_ID=#{criteria.displayId}
  </if>
  <if test="criteria.id != null">
    ID=#{criteria.id}
  </if>
 </sql>

DISPLAY_ID=#{criteria.displayId}
ID=#{criteria.ID}
查询将正确运行并执行更新

我的问题是,如果我在条件中有和键,为什么有时更新会正确运行,有时我会出现错误?

两件事:

  • 删除多余的
    }

  • 在每个条件前面加上
    标记将始终删除第一个标记

    和DISPLAY_ID=#{criteria.displayId} 和ID=#{criteria.ID}


我建议在mybatis中启用查询日志记录,并检查它们在运行和不运行时的情况。有些东西与你的描述不符。您所说的导致问题的查询没有任何
,因此删除
是没有帮助的。在有
或没有
的情况下,查询打印是相同的
更新行集显示\u ID=?其中ID=是可以的,但是如果条件有
的话,我会得到那个错误。这就是为什么我觉得很奇怪。我认为这可能是一个配置问题,但我仍然找不到解决方案。需要两个案例的mybatis日志,以及两个案例的完整配置。您写道,您“仅”删除了
,但
的定义不仅在
中有所不同,因此有些内容仍然不匹配。
 <sql id="rowCriteria">
  <if test="criteria.displayId} != null">
    DISPLAY_ID=#{criteria.displayId}
  </if>
  <if test="criteria.id != null">
    ID=#{criteria.id}
  </if>
 </sql>