【问题标题】:Using MyBatis with Oracle XMLType function "existsNode()"将 MyBatis 与 Oracle XMLType 函数“existsNode()”一起使用
【发布时间】:2011-10-24 16:00:26
【问题描述】:

我有以下情况。 这是我的mybatis sql语句:

<select id="select" parameterType="String" resultMap="urlList">
    select 
                x.t002_id
    from
                 t002_metadata x  
    where
        existsNode(x.t002_xml, ?) = 1;
</select>

所以当我从包装类调用 select 方法并使用 xpath 表达式设置字符串参数时,会显示以下错误消息:

Missing IN or OUT parameter at index:: 1

难道mybatis不能用oracle的existNode方法做prepared statement吗??

提前致谢!

【问题讨论】:

    标签: oracle xpath mybatis


    【解决方案1】:

    这是可能的。你不应该编码 ?进入你的 MyBatis xml。 MyBatis 有专门的动态 sql 语言,建议阅读MyBatis 3 User Guide

    更改你的 sql 映射,

    <select id="select" parameterType="String" resultMap="urlList">
        select 
                    x.t002_id
        from
                     t002_metadata x  
        where
            existsNode(x.t002_xml, #{id}) = 1;
    </select>
    

    它可能不是#{id},这取决于你如何从Mybatis调用select。例如,您可能正在使用@Param 标记。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-11
      • 2015-08-25
      • 2013-06-29
      • 1970-01-01
      相关资源
      最近更新 更多