ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Berry" <chriswbe...@gmail.com>
Subject <parameterMap> and <update> ???
Date Tue, 04 Jul 2006 14:34:41 GMT
Greetings,
This question is related to a previous post I previously made about
<selectkey>, but this one is about using <update> and <parameterMap>

I am using iBatis coupled with Axis. This is a great combination. Axis
generates "XMLBeans" for the Request/Response, and I map them directly
into SQLMaps using iBatis. Thus, very little code is required.

Axis tends to wrap primitives (from the XSD) in it's own types (e.g.
UnsignedLong). This is not normally a problem, except when dealing
with keys.

I am having a great deal of trouble getting <parameterMap> to work
with <update>. Could someone please help?? I must be doing something
silly, but I cannot see what it is???

Thanks,
-- Chris

Details follow::

  <parameterMap class="blogEntryClass" id="blogEntryParams" >
    <parameter property="name" />
    <parameter property="title" />
    <parameter property="text" />
    <parameter property="updateUTC" />
    <parameter property="id"
            jdbcType="INTEGER"
            javaType="org.apache.axis.types.UnsignedLong"
            typeHandler="etrade.utils.ibatis.UnsignedLongTypeHandler"  />
  </parameterMap>

  <update id="updateBlogEntry" parameterMap="blogEntryParams">
    update Blog set Name=#name#, Title=#title#, Text=#text#,
UpdateUTC=#updateUTC# where Id=#id#
  </update>

I always get a
    [junit] --- The error occurred in config/sqlMap-blog.xml.
    [junit] --- The error occurred while applying a parameter map.
    [junit] --- Check the blogEntryParams.
    [junit] --- Check the parameter mapping for the 'name' property.
    [junit] --- Cause: java.sql.SQLException: Parameter index out of
range (1 > number of parameters, which is 0).]; nested exception is
com
.ibatis.common.jdbc.exception.NestedSQLException:

I get this error in whatever order I put together the <parameterMap>!!!

The BlogEntry_t Class looks like this::

public class BlogEntry_t  implements java.io.Serializable {
    .....
    public org.apache.axis.types.UnsignedLong getId() {
        return id;
    }
    public void setId(org.apache.axis.types.UnsignedLong id) {
        this.id = id;
    }
    ......

I cannot see what is wrong with my <parameterMap> ????

-----------------------------------------------------------------------
But if I DON'T use a <parameterMap>, and do this

  <update id="updateBlogEntry" parameterClass="blogEntryBean">
    update Blog set Name=#name#, Title=#title#, Text=#text#,
UpdateUTC=#updateUTC# where Id=#idInt#
  </update>

And then build a "wrapper Bean", like this

public class BlogEntryBean
  extends BlogEntry_t
{
.....
  public BlogEntryBean( BlogEntry_t base )
  {
    .....
  }

  .....
  public int getIdInt()
  {
    org.apache.axis.types.UnsignedLong uid = super.getId();
    return uid.intValue();
  }
}

And call like this::
    getSqlMapClientTemplate().update( "updateBlogEntry", new
BlogEntryBean(entry)  );

Then it works perfectly.

But I really don't want to use a wrapper Bean. It would be so much
cleaner without one.
(I am trying to establish a pattern for building Axis/iBatis web
services at my company)

Thanks,
-- Chris

Mime
View raw message