ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Berry" <chriswbe...@gmail.com>
Subject Re: <parameterMap> and <update> ???
Date Tue, 04 Jul 2006 16:41:46 GMT
Thanks Jeff.
For posterity (and to save me and others the trouble of finding the
pdf in SVN ;-) would you mind posting the syntax??
Thank you.
Cheers,
-- Chris

On 7/4/06, Jeff Butler <jeffgbutler@gmail.com> wrote:
>
> If you use a parameter map, then you need to use question marks in the
> statement rather than named parameters.  This is why we rarely recommend
> using formal parameters maps - the inline maps seem more intuitive.
>
> There is syntax with inline parameter maps to add type a type handler - see
> the latest sqlmap pdf in SVN for details (I just recently added
> documentation for it, but it's been available for quite some time).
>
>
> Jeff Butler
>
>
>
> On 7/4/06, Chris Berry <chriswberry@gmail.com> wrote:
> > 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