ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Berry" <chriswbe...@gmail.com>
Subject When <selectkey> requires a TypeHandlers...
Date Tue, 04 Jul 2006 14:10:11 GMT
Greetings,
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.

Can someone please explain how to use a TypeHandler with <selectkey>??
It seems that <selectkey> needs the ability to add a TypeHandler??
(BTW: I also tried this unsuccessfully with a <parameterMap>, but I
always got an "index out of range" error)

Thanks,
-- Chris

Details follow...

When I use the following  (for MySQL)

  <insert id="insertBlogEntryMySQL" parameterClass="blogEntryClass" >
    insert into Blog (Name, Title, Text) values (#name#, #title#, #text#)

    <selectKey keyProperty="id"
resultClass="org.apache.axis.types.UnsignedLong" >
      select LAST_INSERT_ID()
    </selectKey>
  </insert>

I get a NullPointerException.
If I use resultClass="int", I get an IllegalArgumentException

Where blogEntryClass contains the following (generated by Axis)

   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;
    }
    .....

NOTE: if I do it all "manually" -- calling "select LAST_INSERT_ID()"
in a separate <select> and call setId( new UnsignedLong( id )) -- then
it all works great...

Thanks,
-- Chris

Mime
View raw message