0

i have following situation. this is my mybatis sql statement:

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

so when i'm calling the select method from the wrapper class and set the string parameter with a xpath expression, the following error message shows up:

Missing IN or OUT parameter at index:: 1

Is it not possible for mybatis to make a prepared statement with existNode method from oracle??

thanks in advance!

BenjaminR
  • 53
  • 1
  • 6

1 Answers1

0

It is possible. You shouldn't code the ? into your MyBatis xml. MyBatis has special language for dynamic sql, I suggest reading the MyBatis 3 User Guide.

Change your sql map,

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

It might not be #{id}, it depends on how you call select from Mybatis. For example, you might be using the @Param tag.

Andy
  • 8,841
  • 8
  • 45
  • 68