Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 87165 invoked from network); 3 Oct 2007 21:27:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2007 21:27:55 -0000 Received: (qmail 90836 invoked by uid 500); 3 Oct 2007 21:27:38 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 90821 invoked by uid 500); 3 Oct 2007 21:27:38 -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 90806 invoked by uid 99); 3 Oct 2007 21:27:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2007 14:27:38 -0700 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Jack.Su@fmr.com designates 192.223.198.27 as permitted sender) Received: from [192.223.198.27] (HELO maillnx-us112.fmr.com) (192.223.198.27) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2007 21:27:40 +0000 Received: from MSGMMKSM02WIN.DMN1.FMR.COM (msgmmksm02win.dmn1.fmr.com [10.33.139.33]) by maillnx-us112.fmr.com (Switch-3.1.8/Switch-3.1.7) with SMTP id l93LRFv5009251 for ; Wed, 3 Oct 2007 17:27:15 -0400 Received: from MSGMMKIV02WIN.DMN1.FMR.COM (10.33.148.31) by MSGMMKSM02WIN.DMN1.FMR.COM (Sigaba Gateway v4.1) with ESMTP id 160832843; Wed, 03 Oct 2007 17:27:15 -0400 Received: from MSGMMKIM01WIN.DMN1.FMR.COM ([172.25.108.46]) by MSGMMKIV02WIN.DMN1.FMR.COM with SMTP_server; Wed, 03 Oct 2007 17:27:15 -0400 Received: from msgmmkclq2win.FMR.COM ([10.33.181.43]) by MSGMMKIM01WIN.DMN1.FMR.COM with Microsoft SMTPSVC(5.0.2195.6713); Wed, 3 Oct 2007 17:27:15 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: How to pass Array as parameter? Date: Wed, 3 Oct 2007 17:27:14 -0400 Message-ID: <744CFC61CF0DFF49987C870D28304B6F024E08E6@MSGMMKCLQ2WIN.DMN1.FMR.COM> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How to pass Array as parameter? Thread-Index: AcgF/TOtg1p8SVR2TPWiu17nAbt4+gABAN5sAAAIeYAAAKfLIA== References: <744CFC61CF0DFF49987C870D28304B6F024E08E5@MSGMMKCLQ2WIN.DMN1.FMR.COM> From: "Yu, Jack" To: X-OriginalArrivalTime: 03 Oct 2007 21:27:15.0187 (UTC) FILETIME=[2B0B8430:01C80604] X-Virus-Checked: Checked by ClamAV on apache.org One minor change to the sample code, I have to use inner most delegate connection. So it is: public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { if (parameter instanceof DBArray) { DBArray arr =3D (DBArray)parameter; Statement stmt =3D setter.getPreparedStatement(); Connection conn =3D stmt.getConnection(); if (conn instanceof DelegatingConnection) { DelegatingConnection dcon =3D (DelegatingConnection) conn; conn =3D dcon.getInnermostDelegate(); } ArrayDescriptor desc =3D new ArrayDescriptor (arr.getSqlType(), conn); =09 /* arr.getData's type is SQLData[] */ parameter =3D new ARRAY(desc, conn, arr.getData()); =20 } setter.setObject(parameter); } -----Original Message----- From: Yu, Jack=20 Sent: Wednesday, October 03, 2007 5:11 PM To: user-java@ibatis.apache.org Subject: How to pass Array as parameter? I would need to pass Array in the call, but I couldn't find out feasible way to wrap around my objects to java.sql.Array. In Oracle, it appears I could use "ARRAY" to create, but ARRAY object need ArrayDescriptor which requires access to Connection object, which I am not sure how to get in the ibatis environment. I am trying to play around the setParameter in TypeHandlerCallback interface, here is what I come out. It works in Oracle environment, but I would like to get some feedback before I check in the code. Thanks. public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { if (parameter instanceof DBArray) { DBArray arr =3D (DBArray)parameter; // convert SQLData[] to Array Statement stmt =3D setter.getPreparedStatement(); Connection conn =3D stmt.getConnection(); ArrayDescriptor desc =3D new ArrayDescriptor (arr.getSqlType(), conn); =09 parameter =3D new ARRAY(desc, conn, arr.getData()); =20 } setter.setObject(parameter); }