ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Esperanza.Echever...@steria.es
Subject i have a question, please, some help
Date Thu, 12 Jan 2006 07:17:12 GMT
hi, we have a problem, we are trying to do this to obtain a cursor from 
oracle calling a stored procedure... 

I have modified the framework to allow all oracle cursors to be mapped by 
a statement's resultMap so you can call the queryForList() method and have 
the oracle cursor results returned in the list. I also added the ability 
to specifiy a resultMap to use with each of the oracle cursor parameters 
to support the queryForObject() call. I have tested this code with IBATIS 
here are my sample sqlMap: 
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">


   <typeAlias alias="Employee" type="test.Employee" />
   <resultMap id="employee-map" class="Employee">
       <result property="name" column="ENAME" />
       <result property="employeeNumber" column="EMPNO" />
       <result property="departmentNumber" column="DEPTNO" />
   <parameterMap id="single-rs" class="map" >
       <parameter property="in1" jdbcType="int" 
javaType="java.lang.Integer" mode="IN"/>
       <parameter property="output1" jdbcType="ORACLECURSOR" mode="OUT"/>  
   <procedure id="GetSingleEmpRs" parameterMap="single-rs" 
        { call scott.example.GetSingleEmpRS(?, ?) }
   <parameterMap id="double-rs" class="map" >
       <parameter property="in1" jdbcType="int" 
javaType="java.lang.Integer" mode="IN"/>
       <parameter property="output1" jdbcType="ORACLECURSOR" mode="OUT" 
resultMap="employee-map" />
       <parameter property="output2" jdbcType="ORACLECURSOR" mode="OUT" 
resultMap="employee-map" /> 
   <procedure id="GetDoubleEmpRs" parameterMap="double-rs" >
       { call scott.example.GetDoubleEmpRS(?, ?, ?) }
Here is my sample code that makes use of the maps: 
package test;
import java.io.Reader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class Main {

                    public static void main(String arg[]) throws Exception 
                        String resource;
                        Reader reader;
                        List list;
                        SqlMapClient sqlMap;
                        resource = "test/SqlMapConfig.xml";
                        reader = Resources.getResourceAsReader (resource);
                        sqlMap = 
                        Map map = new HashMap();
                        map.put("in1", new Integer(10));
                        // use queryForList because the procedure map 
defines a resultmap
                        // for the statement
                        list = sqlMap.queryForList("GetSingleEmpRs", map); 

                        System.out.println( list );
                        map = new HashMap();
                        map.put("in1", new Integer(10));
                        // use queryForObject because the procedure map 
does not define a 
                        // result map for the statement
                        sqlMap.queryForObject("GetDoubleEmpRs", map);
                        System.out.println( map.get("output1"));
                        System.out.println( map.get("output2"));

but we obtain an error about the xml and the dtd, we have the version of 
ibatis so we have seen that in the dtd is correct?? please, 
some help.... 
how can we have the version in the ibatis web we downloaded the ... but this doesn´t allow to put a resultMap inside the 
parameter in parameterMap. Please, help!!! 
thanks in advance!!!


Esperanza Echeverría de Miguel
Steria España http://www.steria.es
C/Menéndez y Pelayo,3 bis 46010 Valencia
Tel: + 34 96 393 87 50 Fax: +34 96 393 87 51

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message