Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 64900 invoked from network); 4 Apr 2007 07:53:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Apr 2007 07:53:43 -0000 Received: (qmail 62972 invoked by uid 500); 4 Apr 2007 07:53:48 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 62806 invoked by uid 500); 4 Apr 2007 07:53:47 -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 62795 invoked by uid 99); 4 Apr 2007 07:53:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 00:53:47 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of gchelidze@magtigsm.ge designates 81.95.160.41 as permitted sender) Received: from [81.95.160.41] (HELO relay.magtigsm.ge) (81.95.160.41) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2007 00:53:39 -0700 Received: from [192.168.9.5] (gchelidze.magti.ge [192.168.9.5]) by relay.magtigsm.ge (8.14.0/8.14.0) with ESMTP id l347rDXa096265 for ; Wed, 4 Apr 2007 11:53:13 +0400 (GET) Message-ID: <46135981.2070204@magtigsm.ge> Date: Wed, 04 Apr 2007 11:53:37 +0400 From: George Chelidze User-Agent: Debian Thunderbird 1.0.2 (X11/20070113) X-Accept-Language: en-us, en MIME-Version: 1.0 To: user-java@ibatis.apache.org Subject: Oracle stored procedure with custom data types Content-Type: multipart/mixed; boundary="------------090702070001080806000504" X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on relay.magtigsm.ge X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-104.3 required=8.0 tests=ALL_TRUSTED,AWL,BAYES_00, USER_IN_WHITELIST autolearn=ham version=3.1.8 This is a multi-part message in MIME format. --------------090702070001080806000504 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, It's my first post to this list, so I'd like to say hello to all of you. I have a procedure: CREATE OR REPLACE PROCEDURE "S"."PREPROCPROC"(aInput in TPreprocInputMessageSet, aOutput out TPreprocOutputMessageSet) is res TPreprocOutputMessageSet; curi TPreprocInputMessage; curo TPreprocOutputMessage; begin res:=TPreprocOutputMessageSet(); res.extend(aInput.Count); FOR i IN aInput.First .. aInput.Last LOOP curi:=aInput(i); curo:=TPreprocOutputMessage(null,null,null); curo.FieldA := curi.FieldA; curo.FieldB := curi.FieldB; curo.FieldC := null; res(i):=curo; END LOOP; aOutput:=res; res.delete; end PreprocProc; and the following custom types: -- CREATE OR REPLACE TYPE TPREPROCINPUTMESSAGESET AS TABLE OF S.TPREPROCINPUTMESSAGE GO -- CREATE OR REPLACE TYPE TPREPROCOUTPUTMESSAGESET AS TABLE OF B1.TPREPROCOUTPUTMESSAGE GO -- CREATE OR REPLACE TYPE TPREPROCINPUTMESSAGE as object ( FieldA varchar2(32), FieldB varchar2(32) ) GO -- CREATE OR REPLACE TYPE TPREPROCOUTPUTMESSAGE as object ( FieldA varchar2(32), FieldB varchar2(32), FieldC varchar2(32) ) GO -- I have attached Main.java, TPreprocTypeHandler.java, SqlMapConfig.xml, SqlMapProcedure.xml files. The main problem that I have is that in TPreprocTypeHandler.getResult(ResultGetter getter) method, getter.getObject().getArray() returns Object[] which contains instances of STRUCT not TPreprocInputMessage, so I have to map them to TPreprocInputMessage myself. Is it possible to tell ibatis to return instances of TPreprocInputMessage instead of instances of STRUCT? Thanks in advance, George --------------090702070001080806000504 Content-Type: text/x-java; name="Main.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Main.java" package ibatis; import com.ibatis.sqlmap.client.SqlMapClient; import ibatis.datatypes.TPreprocInputMessage; import ibatis.datatypes.TPreprocInputMessageSet; import ibatis.datatypes.TPreprocOutputMessage; import ibatis.datatypes.TPreprocOutputMessageSet; import ibatis.util.DBConnector; import java.util.HashMap; public class Main { public static void main(String[] args) { try { SqlMapClient sqlMapClient = DBConnector.getSqlMapClient(); TPreprocInputMessage[] inMessages = new TPreprocInputMessage[10]; for (int i = 0; i < 10; i++) { inMessages[i] = new TPreprocInputMessage(null, null); } TPreprocInputMessageSet inMessageSet = new TPreprocInputMessageSet(inMessages); TPreprocOutputMessageSet outMessageSet = new TPreprocOutputMessageSet(); HashMap params = new HashMap(); params.put("inMessageSet", inMessageSet); params.put("outMessageSet", outMessageSet); sqlMapClient.queryForObject("Procedure.PreprocProc", params); } catch (Exception ex) { ex.printStackTrace(); } } } --------------090702070001080806000504 Content-Type: text/xml; name="SqlMapConfig.xml" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SqlMapConfig.xml" --------------090702070001080806000504 Content-Type: text/xml; name="SqlMapProcedure.xml" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SqlMapProcedure.xml" {call PREPROCPROC(?,?)} --------------090702070001080806000504 Content-Type: text/x-java; name="TPreprocTypeHandler.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TPreprocTypeHandler.java" package ibatis.handler; import com.ibatis.sqlmap.client.extensions.ParameterSetter; import com.ibatis.sqlmap.client.extensions.ResultGetter; import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; import com.ibatis.sqlmap.engine.type.JdbcTypeRegistry; import java.sql.SQLException; import java.sql.Types; public class TPreprocTypeHandler implements TypeHandlerCallback { static { JdbcTypeRegistry.setType("TPREPROCOINPUTMESSAGESET", Types.ARRAY); JdbcTypeRegistry.setType("TPREPROCOUTPUTMESSAGESET", Types.ARRAY); }; public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { setter.setObject(parameter); } public Object getResult(ResultGetter getter) throws SQLException { return getter.getObject(); } public Object valueOf(String s) { return null; } } --------------090702070001080806000504--