ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gareth Moorst" <Gareth.Moo...@Phones4u.co.uk>
Subject Parameter Maps AND dynamic sql at the same time
Date Fri, 28 Oct 2005 09:21:42 GMT
Before acting on this e-mail or opening any attachments you are advised to read 
The Caudwell Holdings group of companies' disclaimer at the end of this e-mail.

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 = ?, 
	where supplier=?

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

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.

Gareth Moorst

Confidentiality Notice
This e-mail is confidential and intended for the use of the named recipient only.  If you
are not the intended recipient please notify us by telephone immediately on +44(0)1782 600600
or return it to us by e-mail.  Please then delete it from your system and note that any use,
dissemination, forwarding, printing or copying is strictly prohibited. Any views or opinions
are solely those of the author and do not necessarily represent those of The Caudwell Holdings
group of companies.

Encryptions and Viruses
Please note that this e-mail and any attachments have not been encrypted.  They may therefore
be liable to be compromised.  Please also note that it is your responsibility to scan this
e-mail and any attachments for viruses.  We do not, to the extent permitted by law, accept
any liability (whether in contract, negligence or otherwise) for any virus infection and/or
external compromise of security and/or confidentiality in relation to transmissions sent by

Activity and use of The Caudwell Holdings group of companies' systems is monitored to secure
its effective use and operation and for other lawful business purposes.  Communications using
these systems will also be monitored and may be recorded to secure effective use and operation
and for other lawful business purposes.

View raw message