You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Es...@steria.es on 2006/01/12 08:17:12 UTC

i have a question, please, some help

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 
2.1.6.598 
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">

<sqlMap>

   <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" />
   </resultMap>
 
   <parameterMap id="single-rs" class="map" >
       <parameter property="in1" jdbcType="int" 
javaType="java.lang.Integer" mode="IN"/>
       <parameter property="output1" jdbcType="ORACLECURSOR" mode="OUT"/>  
 
   </parameterMap>
 
   <procedure id="GetSingleEmpRs" parameterMap="single-rs" 
resultMap="employee-map">
        { call scott.example.GetSingleEmpRS(?, ?) }
   </procedure>
 
   <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" /> 
   </parameterMap> 
 
   <procedure id="GetDoubleEmpRs" parameterMap="double-rs" >
       { call scott.example.GetDoubleEmpRS(?, ?, ?) }
   </procedure>
</sqlMap> 
Here is my sample code that makes use of the maps: 
Main.java 
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 = 
SqlMapClientBuilder.buildSqlMapClient(reader);
                        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("--------------------");
                        System.out.println( list );
                        System.out.println("--------------------");
 
                        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("--------------------");
                        System.out.println( map.get("output1"));
                        System.out.println( map.get("output2"));
                        System.out.println("--------------------");
 
 
                    }
}


but we obtain an error about the xml and the dtd, we have the version of 
ibatis 

2.1.6.589 so we have seen that in 2.1.6.598 the dtd is correct?? please, 
some help.... 
how can we have the version 2.1.6.598? in the ibatis web we downloaded the 
2.1.6.589 ... 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
esperanza.echeverria@steria.es

 
 

Re: i have a question, please, some help

Posted by Road Mountain <ro...@yahoo.com>.
Do you use the modified libraries Michael Fagan from 
  http://opensource2.atlassian.com/confluence/oss/pages/viewpageattachments.action?pageId=561. I had the same issue with refcursors, but after downloading the libraries (which has the dtd), XMLSpy (xml editor) didn't complain about the dtd. I hope this helps.
   
   
  Thanks.
  

Esperanza.Echeverria@steria.es wrote:
  
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 2.1.6.598   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">

<sqlMap>

  <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" />
  </resultMap>
  
  <parameterMap id="single-rs" class="map" >
      <parameter property="in1" jdbcType="int" javaType="java.lang.Integer" mode="IN"/>
      <parameter property="output1" jdbcType="ORACLECURSOR" mode="OUT"/>      
  </parameterMap>
   
  <procedure id="GetSingleEmpRs" parameterMap="single-rs" resultMap="employee-map">
       { call scott.example.GetSingleEmpRS(?, ?) }
  </procedure>
  
  <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" />         
   </parameterMap> 
   
  <procedure id="GetDoubleEmpRs" parameterMap="double-rs" >
      { call scott.example.GetDoubleEmpRS(?, ?, ?) }
  </procedure>
</sqlMap>   Here is my sample code that makes use of the maps:   Main.java 
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 = SqlMapClientBuilder.buildSqlMapClient(reader);
                       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("--------------------");
                       System.out.println( list );
                       System.out.println("--------------------");
                       
                       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("--------------------");
                       System.out.println( map.get("output1"));
                       System.out.println( map.get("output2"));
                       System.out.println("--------------------");
                       
                          
                   }
}
  


but we obtain an error about the xml and the dtd, we have the version of ibatis                 2.1.6.589 so we have seen that in 2.1.6.598 the dtd is correct?? please, some help.... 
how can we have the version 2.1.6.598? in the ibatis web we downloaded the 2.1.6.589 ... 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
esperanza.echeverria@steria.es
      
  


		
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
 Photo Books. You design it and we’ll bind it!