Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 37506 invoked from network); 4 Jul 2006 23:29:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Jul 2006 23:29:00 -0000 Received: (qmail 61191 invoked by uid 500); 4 Jul 2006 23:28:58 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 61174 invoked by uid 500); 4 Jul 2006 23:28:57 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 61159 invoked by uid 99); 4 Jul 2006 23:28:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 16:28:57 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.92.172 as permitted sender) Received: from [66.249.92.172] (HELO ug-out-1314.google.com) (66.249.92.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 16:28:56 -0700 Received: by ug-out-1314.google.com with SMTP id k3so1434041ugf for ; Tue, 04 Jul 2006 16:28:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=L6S2ulL3F6NrpWMz83laZl/AXcTv453iawaX++qclSOYo0wwpqTxmSYXxmUITqUx/rWpiIjsIDM0yIpQSTxz5iyaieKBBXYC7Nie+ASSuFS1vS5pLrhc/5n78cWymIhNahK3z9QaZq7KC61TOrDUxgkitVhiBSfu0T9ekoTVrxM= Received: by 10.66.221.19 with SMTP id t19mr7066966ugg; Tue, 04 Jul 2006 16:28:34 -0700 (PDT) Received: by 10.66.238.18 with HTTP; Tue, 4 Jul 2006 16:28:34 -0700 (PDT) Message-ID: Date: Tue, 4 Jul 2006 18:28:34 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: and ??? In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_37430_27233390.1152055714423" References: <84fb18c70607040734i5e2e4a11ifa6bff0d50ed23d8@mail.gmail.com> <84fb18c70607040941keb3f8f5kaf2153ba438fc73a@mail.gmail.com> <84fb18c70607041020w40edcd0ej4818870afafa9c4d@mail.gmail.com> <84fb18c70607041538h77ee25adx414e0f1b417aab9d@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_37430_27233390.1152055714423 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hold off on the JIRA issue - I just wrote a test and the select key DOES honor the type handler if you specify it on the generated field. This this mapping worked in my test: select max(id) + 1 from Animal insert into Animal values (#id,handler=test.WierdKeyHandler#, #type#, #name#) Try it out. Jeff Butler On 7/4/06, Jeff Butler wrote: > > Currently there is no way to use a type handler with - but I > think that would be a logical enhancement for iBATIS. If you want, make a > new JIRA issue for this. Or, if you don't want to access JIRA let me know > and I'll do it. > > Jeff Butler > > > On 7/4/06, Chris Berry wrote: > > > > This stuff works great!! > > Is there anyway to use this to specify a TypeHandler with ?? > > > > > > > > insert into Blog (Name, Title, Text) values (#name#, #title#, #text#) > > > > > > select LAST_INSERT_ID() > > > > > > > > Thanks, > > -- Chris > > > > > > On 7/4/06, Chris Berry wrote: > > > Thank you Jeff > > > > > > On 7/4/06, Jeff Butler wrote: > > > > > > > > There's a link here: > > > > > > > > http://ibatis.apache.org/javadownloads.html > > > > > > > > "Latest Open Office Documents in Subversion", you want > > iBATIS-SqlMaps-2.pdf. > > > > > > > > The syntax is: > > > > > > > > #propertyName,javaType=?,jdbcType=?,mode=?,nullValue=?,handler=?# > > > > > > > > > > > > Jeff Butler > > > > > > > > > > > > On 7/4/06, Chris Berry wrote: > > > > > 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 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 > > > > > > > , but this one is about using and > > > > > > > > > > > > > > > > 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 to > > work > > > > > > > with . Could someone please help?? I must be doing > > something > > > > > > > silly, but I cannot see what it is??? > > > > > > > > > > > > > > Thanks, > > > > > > > -- Chris > > > > > > > > > > > > > > Details follow:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > jdbcType="INTEGER" > > > > > > > > > > > javaType="org.apache.axis.types.UnsignedLong " > > > > > > > > > > > > > > > > > typeHandler="etrade.utils.ibatis.UnsignedLongTypeHandler" > > > > > > /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > update Blog set Name=#name#, Title=#title#, Text=#text#, > > > > > > > UpdateUTC=#updateUTC# where Id=#id# > > > > > > > > > > > > > > > > > > > > > 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 > > > > !!! > > > > > > > > > > > > > > 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 ???? > > > > > > > > > > > > > > > > > > > > > > > > > > ----------------------------------------------------------------------- > > > > > > > But if I DON'T use a , and do this > > > > > > > > > > > > > > > > > > > > > update Blog set Name=#name#, Title=#title#, Text=#text#, > > > > > > > UpdateUTC=#updateUTC# where Id=#idInt# > > > > > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------=_Part_37430_27233390.1152055714423 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hold off on the JIRA issue - I just wrote a test and the select key DOES honor the type handler if you specify it on the generated field.  This this mapping worked in my test:
 
<insert id="testInsert" parameterClass="test.Animal">
  <selectKey resultClass="test.WierdKey" keyProperty="id">
    select max(id) + 1 from Animal <!-- bad practice - just for test -->
  </selectKey>
  insert into Animal values (#id,handler=test.WierdKeyHandler#, #type#, #name#)
</insert>
 
Try it out.
 
Jeff Butler


 
On 7/4/06, Jeff Butler <jeffgbutler@gmail.com> wrote:
Currently there is no way to use a type handler with <selectKey> - but I think that would be a logical enhancement for iBATIS.  If you want, make a new JIRA issue for this.  Or, if you don't want to access JIRA let me know and I'll do it.
 
Jeff Butler

 
On 7/4/06, Chris Berry <chriswberry@gmail.com > wrote:
This stuff works great!!
Is there anyway to use this to specify a TypeHandler with <selectkey> ??

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

   <selectKey keyProperty="idInt" resultClass="int" >
     select LAST_INSERT_ID()
   </selectKey>
</insert>

Thanks,
-- Chris


On 7/4/06, Chris Berry < chriswberry@gmail.com> wrote:
> Thank you Jeff
>
> On 7/4/06, Jeff Butler <jeffgbutler@gmail.com > wrote:
> >
> > There's a link here:
> >
> > http://ibatis.apache.org/javadownloads.html
> >
> > "Latest Open Office Documents in Subversion", you want iBATIS-SqlMaps-2.pdf.
> >
> > The syntax is:
> >
> > #propertyName,javaType=?,jdbcType=?,mode=?,nullValue=?,handler=?#
> >
> >
> > Jeff Butler
> >
> >
> > On 7/4/06, Chris Berry < chriswberry@gmail.com> wrote:
> > > 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
> > > > >
> > > >
> > > >
> > >
> >
> >
>


------=_Part_37430_27233390.1152055714423--