logo       

Re: Parameter Maps AND dynamic sql at the same time: msg#00326

Subject: Re: Parameter Maps AND dynamic sql at the same time
Hi

In the iBatis-SqlMaps-2.pdf (page 16) it states:

Note! Dynamic mapped statements (described below) only support inline parameters
and do not work with
parameter maps.

Regards
Neil

Quoting g m <gazj2ee@xxxxxxxxxxx>:

> Well spotted - it appears I pasted the wrong xml
> fragment. My mistake.
> Here's the correct one, along with the parameter map
> I'm using.
>
> <insert id="insertSupplierExtras"
> parameterMap="SupplierExtrasParam">
>       insert into <dynamic><isEqual property="status"
> compareValue="1">supplierextrastm</isEqual><isEqual
> property="status"
> compareValue="0">supplierextras</isEqual></dynamic>
>       ( preferredsupplier, contactname, websiteaddress,
> companyregno, emailaddress, supplier) values (?, ?, ?,
> ?, ?, ?)</insert>
>
>
> <parameterMap class="SupplierIF"
> id="SupplierExtrasParam">
>               <parameter property="preferredSupplier"
>
typeHandler="com.phones4u.datamanagement.datamodel.ibatis.typehandler.SmallIntBooleanTypeHandler"/>
>               <parameter property="contactName" />
>               <parameter property="webAddress"/>
>               <parameter property="companyRegistrationNumber" />
>               <parameter property="emailAddress"/>
>               <parameter property="code"/>
>       </parameterMap>
>
> I've just tried it again to confirm the error (I
> played around with it a lot trying to get it to work,
> so I wanted to make sure that this sql fragment is
> definitely being called) and the error stops happening
> if I remove the <dynamic> element from the <insert>,
> giving me this debug output:
>
>
> DEBUG [AWT-EventQueue-0] - {pstm-100017}
> PreparedStatement:   insert into supplierextrastm  (
> preferredsupplier, contactname, websiteaddress,
> companyregno, emailaddress, supplier) values (?, ?, ?,
> ?, ?, ?)
> DEBUG [AWT-EventQueue-0] - {pstm-100017} Parameters:
> [1, c, , c, , C]
> DEBUG [AWT-EventQueue-0] - {pstm-100017} Types:
> [java.lang.Short, java.lang.String, java.lang.String,
> java.lang.String, java.lang.String, java.lang.String]
>
>
> Cheers,
> Gareth.
>
> PS Apologies for the huge disclaimer - the legal
> department at my company have far too much time on
> their hands.
> --- Larry Meadors <lmeadors@xxxxxxxxxx> wrote:
>
> > There is something else going wrong here..
> >
> > In the stack trace, it shows this message:
> > "Check the
> > Supplier.insertSupplierExtras-InlineParameterMap"
> >
> > That tells me that you were running
> > "insertSupplierExtras" with an inline
> > parameter map.
> >
> > But the statement sent was "updateSupplierExtras"
> > with an explicit parameter
> > map.
> >
> > I know that dynamic SQL and parameter maps work, so
> > I think we are missing
> > some pieces of the puzzle here.
> >
> > Larry
> >
> >
> > PS: Can you please trim the massive disclaimer, or
> > use another account when
> > posting? GMail is free, and works great for this
> > stuff.
> >
> >
> > On 10/28/05, Gareth Moorst
> > <Gareth.Moorst@xxxxxxxxxxxxxx> wrote:
> > >
> > > I'm trying to write insert/update statements that
> > can have their table
> > > dynamically altered, but I'm having problems with
> > any statements that use
> > > parameter maps...
> > >
> > > <update id="updateSupplierExtras"
> > parameterMap="SupplierExtrasParam">
> > > update <dynamic><isEqual property="status"
> > >
> > compareValue="1">supplierextrastm</isEqual><isEqual
> > property="status"
> > >
> > compareValue="0">supplierextras</isEqual></dynamic>
> > set
> > > preferredsupplier = ?,
> > > contactname = ?,
> > > websiteaddress = ?,
> > > companyregno = ?,
> > > emailaddress=?
> > > where supplier=?
> > > </update>
> > >
> > > If I use inline parameters, then I don't have a
> > problem, but when I try to
> > > use either a <dynamic> clause or a $tableName$
> > clause in the map, I get this
> > > error :
> > >
> > >
> > > DEBUG [AWT-EventQueue-0] - {pstm-100017}
> > PreparedStatement: insert into
> > > supplierextrastm ( preferredsupplier, contactname,
> > websiteaddress,
> > > companyregno, emailaddress, supplier) values (?,
> > ?, ?, ?, ?, ?)
> > > DEBUG [AWT-EventQueue-0] - {pstm-100017}
> > Parameters: []
> > > DEBUG [AWT-EventQueue-0] - {pstm-100017} Types: []
> > > WARN [AWT-EventQueue-0] - Error saving supplier
> > >
> > org.springframework.jdbc.UncategorizedSQLException:
> > SqlMapClient
> > > operation; uncategorized SQLException for SQL [];
> > SQL state [IX000]; error
> > > code [-79749];
> > > --- The error occurred while applying a parameter
> > map.
> > > --- Check the
> > Supplier.insertSupplierExtras-InlineParameterMap.
> > > --- Check the statement (update failed).
> > > --- Cause: java.sql.SQLException: Number of input
> > values does not match
> > > number of question marks;
> > >
> > > Looking at the trace, it seems that when I use any
> > form of dynamic sql,
> > > none of the parameters are passed. Is this the
> > correct behaviour? Is it
> > > possible to use dynamic sql and parameter maps at
> > the same time?
> > >
> > > I'm using iBatis 2.1.5.
> > >
> > > Cheers,
> > > Gareth Moorst
> > >
> > >
> >
>
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with
> voicemail http://uk.messenger.yahoo.com
>






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe