Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 22423 invoked from network); 12 Dec 2008 23:08:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Dec 2008 23:08:54 -0000 Received: (qmail 14362 invoked by uid 500); 12 Dec 2008 23:09:05 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 14342 invoked by uid 500); 12 Dec 2008 23:09:05 -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 14332 invoked by uid 99); 12 Dec 2008 23:09:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Dec 2008 15:09:05 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of larry.meadors@gmail.com designates 209.85.218.16 as permitted sender) Received: from [209.85.218.16] (HELO mail-bw0-f16.google.com) (209.85.218.16) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Dec 2008 23:08:44 +0000 Received: by bwz9 with SMTP id 9so4710646bwz.0 for ; Fri, 12 Dec 2008 15:08:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=KYB9FNzcejrfF33wmIMmrlI8InOxtTZF9Fg7Yuhb1pw=; b=dRMm134wCjYGXM8z+LRayjRwZhKn6LZxn5ez7WNkl9KYSB6SsQCj26FlUmCNyKWRBV /3E7FN7KcBTht3vR3+o/bXniPg3BeI+MskEJFwgzzvXCGB6ArK2M/PTogWXDzrdMZQHz 2gne+CRefK0HpvZJLUpPkqgdyesJ/1+c42q7o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Fqi0zPUZqA0W+xqST4SVNcao446qAH8aVuT4ePAMbZRiRO7Bbqz41x3Ii6mIpSkMb+ wwPTU9r2XGEJsR3c0OZ573evJKUwnak622SW/j6KEfESWvGIEH/tlmj1JIMYwZPw/iKG +v44kYAKL5oKKISVC1zV9LmY1UJEugeusUS9c= Received: by 10.181.136.4 with SMTP id o4mr1467903bkn.0.1229123302370; Fri, 12 Dec 2008 15:08:22 -0800 (PST) Received: by 10.181.48.19 with HTTP; Fri, 12 Dec 2008 15:08:22 -0800 (PST) Message-ID: Date: Fri, 12 Dec 2008 16:08:22 -0700 From: "Larry Meadors" Reply-To: larry.meadors@gmail.com To: user-java@ibatis.apache.org Subject: Re: Trying to use HashMap as a param object for an UPDATE - getting an exception In-Reply-To: <20981745.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <41A58663201546498213FCA63B54B8721BA8503502@tormail02.cihi.ca> <20981745.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Actually...it's even easier. No parameter class or map required. Larry On Fri, Dec 12, 2008 at 12:12 PM, joeweder wrote: > > You do not have to map a Map as a parameter. Just tell iBatis that the > parameter is a map and use the key-names you used to populate it in your > update (note: use parameterClass instead of parameterMap). > > Map s1 = new HashMap(); > s1.put("code", "001"); > s1.put("description", "Region Transaction upd"); > s1.put("fiscalYear", "2005"); > s1.put("id", "1501"); > client.update("updateSector", s1); > > > UPDATE SECTOR SET SECTOR_DESC = #description# WHERE SECTOR_ID = #id# > > > That's all there is to it. > > > Alex Savitsky-2 wrote: >> >> Hi, >> >> I'm trying to execute an update, with a HashMap for parameter (there's no >> business object to pass). The mapping file is as follows (iBATIS >> v.2.3.0.677) >> >> >> > "http://ibatis.apache.org/dtd/sql-map-2.dtd"> >> >> >> >> >> >> > javaType="java.lang.Integer" /> >> >> >> >> >> >> >> >> >> >> UPDATE SECTOR SET SECTOR_DESC = #description# WHERE SECTOR_ID = #id# >> >> >> >> Both parameters and results are Maps, and the select works when I pass it >> a parameter map, whether it has all the properties, or not. Update, >> however, fails: >> >> Map s1 = new HashMap(); >> s1.put("code", "001"); >> s1.put("description", "Region Transaction upd"); >> s1.put("fiscalYear", "2005"); >> s1.put("id", "1501"); >> client.update("updateSector", s1); >> >> com.ibatis.common.jdbc.exception.NestedSQLException: >> --- The error occurred in ca/cihi/cmdb/model/Sector.xml. >> --- The error occurred while applying a parameter map. >> --- Check the Sector.sector. >> --- Check the parameter mapping for the 'id' property. >> --- Cause: java.sql.SQLException: Invalid column index >> at >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91) >> at >> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505) >> at >> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90) >> at >> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:67) >> at >> ca.cihi.cmdb.service.MaintenanceService.update(MaintenanceService.java:52) >> ... 29 more >> Caused by: java.sql.SQLException: Invalid column index >> at >> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) >> at >> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) >> at >> oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227) >> at >> oracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:4754) >> at >> oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:4717) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:585) >> at >> com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:70) >> at $Proxy2.setString(Unknown Source) >> at >> com.ibatis.sqlmap.engine.type.StringTypeHandler.setParameter(StringTypeHandler.java:30) >> at >> com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHandler.java:69) >> at >> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165) >> at >> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125) >> at >> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79) >> at >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200) >> at >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78) >> ... 33 more >> >> Am I doing something wrong? >> >> Thanks, >> >> Alex >> > > -- > View this message in context: http://www.nabble.com/Trying-to-use-HashMap-as-a-param-object-for-an-UPDATE---getting-an-exception-tp20922966p20981745.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >