Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 86632 invoked from network); 7 Apr 2009 08:52:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Apr 2009 08:52:57 -0000 Received: (qmail 10092 invoked by uid 500); 7 Apr 2009 08:52:56 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 10045 invoked by uid 500); 7 Apr 2009 08:52:56 -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 10037 invoked by uid 99); 7 Apr 2009 08:52:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 08:52:56 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 08:52:46 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Lr72f-0004dw-4U for user-java@ibatis.apache.org; Tue, 07 Apr 2009 01:52:25 -0700 Message-ID: <22924852.post@talk.nabble.com> Date: Tue, 7 Apr 2009 01:52:25 -0700 (PDT) From: beppes To: user-java@ibatis.apache.org Subject: Update Postgres Array with IBatis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: superbeppe@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org Hi to everybody. I'm new to this forum. I need to update an array of integers in Postgres with Ibatis 2.3.4 (and Spring). I want to execute the following query: UPDATE data SET=3D'{1,2}' WHERE dataid=3D10 The query is UPDATE data =09 =09 #arrayData[]# =09 =20 WHERE dataid=3D#dataId# The method realized public void updateData(int dataId, MyData mydata) { Map params =3D new HashMap(); List arrayData =3D mydata.getIntegerArray(); params.put("dataId", dataId); params.put("arrayData", arrayData); this.getSqlMapClientTemplate().update("updateQuery", params); } Executing the query I get the following response (arrayData contains 2 values): Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: =20 --- The error occurred while applying a parameter map. =20 --- Check the updateData-InlineParameterMap. =20 --- Check the parameter mapping for the 'arrayData[1]' property. =20 --- Cause: org.postgresql.util.PSQLException: The column index is out of range: 2, number of columns: 1 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(Ma= ppedStatement.jav2009-04-07 10:27:26,727 DEBUG [java.sql.Connection] - {conn-100043} Connection 2009-04-07 10:27:26,729 DEBUG [java.sql.Connection] - {conn-100043} Preparing Statement: UPDATE data SET arrayData =3D = =20 '{ ? , ? }' WHERE dataId= =3D? a:107) =09at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorD= elegate.java:457) =09at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.ja= va:90) =09at org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(Sql= MapClientTemplate.java:413) =09at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTem= plate.java:209) =09... 43 more Caused by: org.postgresql.util.PSQLException: Indice di colonna, 2, =C3=A8 maggiore del numero di colonne 1. =09at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:52= ) =09at org.postgresql.core.v3.SimpleParameterList.setLiteralParameter(SimpleParame= terList.java:113) =09at org.postgresql.jdbc2.AbstractJdbc2Statement.bindLiteral(AbstractJdbc2Statem= ent.java:2108) =09at org.postgresql.jdbc2.AbstractJdbc2Statement.setInt(AbstractJdbc2Statement.j= ava:1151) =09at org.apache.commons.dbcp.DelegatingPreparedStatement.setInt(DelegatingPrepar= edStatement.java:117) =09at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) =09at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3= 9) =09at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp= l.java:25) =09at java.lang.reflect.Method.invoke(Method.java:585) =09at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedSta= tementLogProxy.java:70) =09at $Proxy9.setInt(Unknown Source) =09at com.ibatis.sqlmap.engine.type.IntegerTypeHandler.setParameter(IntegerTypeHa= ndler.java:30) =09at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHa= ndler.java:69) =09at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameter(Parame= terMap.java:166) =09at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameters(Param= eterMap.java:126) =09at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.ja= va:78) =09at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate= (MappedStatement.java:216) =09at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(Ma= ppedStatement.java:94) =09... 47 more I've also tried the same query with this variant public void updateData(int dataId, MyData mydata) { Map params =3D new HashMap(); int[] arrayData =3D mydata.getIntArray(); params.put("dataId", dataId); params.put("arrayData", arrayData); this.getSqlMapClientTemplate().update("updateQuery", params); } With the same result. Could someone suggest me a solution? --=20 View this message in context: http://www.nabble.com/Update-Postgres-Array-w= ith-IBatis-tp22924852p22924852.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com.