Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 99073 invoked from network); 7 Jul 2006 00:20:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2006 00:20:13 -0000 Received: (qmail 6773 invoked by uid 500); 7 Jul 2006 00:20:12 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 6236 invoked by uid 500); 7 Jul 2006 00:20:10 -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 6225 invoked by uid 99); 7 Jul 2006 00:20:10 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 17:20:10 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of chriswberry@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; Thu, 06 Jul 2006 17:20:09 -0700 Received: by ug-out-1314.google.com with SMTP id k3so2352686ugf for ; Thu, 06 Jul 2006 17:19:48 -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:content-transfer-encoding:content-disposition:references; b=bssfgcNodkLlcbMHdUWAFHWTlCH/tCEH091xKsdtEl3WEe8eRv+EYAXRq6bmqYqsNKOpXIxVKq4SOw+27+wIQE+9WhGrJfMceJhSjMqsZeUx77TqsmssgoVhQ8wUowFJBMcYqmNQYhJSGilRKhPAg7niBHQV+zcR+QT1Pwy/6As= Received: by 10.67.89.5 with SMTP id r5mr1363068ugl; Thu, 06 Jul 2006 17:19:48 -0700 (PDT) Received: by 10.66.243.7 with HTTP; Thu, 6 Jul 2006 17:19:48 -0700 (PDT) Message-ID: <84fb18c70607061719p57df5baby39706b5f18504e5a@mail.gmail.com> Date: Thu, 6 Jul 2006 19:19:48 -0500 From: "Chris Berry" To: user-java@ibatis.apache.org Subject: Re: and ??? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <84fb18c70607040734i5e2e4a11ifa6bff0d50ed23d8@mail.gmail.com> <84fb18c70607040941keb3f8f5kaf2153ba438fc73a@mail.gmail.com> <84fb18c70607041020w40edcd0ej4818870afafa9c4d@mail.gmail.com> <84fb18c70607041538h77ee25adx414e0f1b417aab9d@mail.gmail.com> <84fb18c70607052136g10bd78e8j736348d3fe11c294@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Yes, you are right. But like I said in the original text, I am wiring Axis-generated "XMLBeans" (i.e. beans generated from the WSDL/XSD definitions of a web service) directly to iBatis SQLMaps. Thus, I can end up with almost zero code!! This is really cool. And I eventually hope to write a code generator for this, so that I can generate CRUD data services "for free". But Axis tends to wrap up integers and the like into it's own type classes (e.g. UnsignedInt, UnsignedLong, etc.). My current workaround solution is to build a "wrapper bean" around the Axis XMLBean to handle the conversion (essentially what you are proposing). But this is defeats the nice direct mapping, where the Axis generated bean is my DAO -- which indeed it is to the rest of the system. The current alternative introduces an unnecessary interim Object. Thanks for all your help, Cheers -- Chris On 7/6/06, Jeff Butler wrote: > > You're right - no way to express the handler here. But I would submit that > you don't need it here. iBATIS will return an Integer from the insert > statement and you can change it to your desired type in your DAO method. > You would right the same kind of code in a type handler. > > > Jeff Butler > > > > On 7/5/06, Chris Berry wrote: > > Does that work with this syntax?? > > I don't see how to express the Handler here?? > > Thanks for all your help. > > Cheers, > > -- Chris > > > > > > INSERT INTO Blog (Name, Title, Text, CreateUTC) > > VALUES (#name#, #title#, #text#, #createUTC#) > > > > > > SELECT LAST_INSERT_ID() > > > > > > > > > > On 7/4/06, Jeff Butler < jeffgbutler@gmail.com> wrote: > > > > > > 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 < chriswberry@gmail.com> 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 < 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 > > > > > > > > > > , 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" > > > > > > > > > /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > parameterMap="blogEntryParams"> > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > parameterClass="blogEntryBean"> > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >