ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Naveen Mansur (nmansur)" <nman...@cisco.com>
Subject Array List of Java beans to Stored Procedure
Date Tue, 16 Dec 2008 15:40:20 GMT
Hi 

        I require to pass array list of java beans to stored proc 

If I send ArrayList with primitive data type it works but fails when
send objects in arrayList.

Error : java.sql.SQLException: Fail to convert to internal
representation

Any Help pointers appreciated 

Type Handler Implementation :

public void setParameter(ParameterSetter setter, Object parameter)

                        throws SQLException {

                if (parameter instanceof ArrayList) {

                        ArrayList arr = (ArrayList) parameter;

                        Statement stmt = setter.getPreparedStatement();

                        Connection conn = stmt.getConnection();

                        ArrayDescriptor desc =
ArrayDescriptor.createDescriptor("PROPERTYVALUE_COL",

                                        conn); // The STRARRAY is the
name of the oracle type

                                                        // created as
the instance of table.

                        parameter = new ARRAY(desc, conn,
arr.toArray());

                }

                setter.setObject(parameter);

        }

XML MAPPING

<parameterMap id="parameters4ab" class="map">

    <parameter property="i_array" jdbcType="PROPERTYVALUE_COL"
javaType="ArrayList"  mode="IN" 

              typeHandler=" StringArrayTypeHandler"/>

              

 <parameter property="employees" javaType="object"
typeName="EMPLOYEE_TBL"

               jdbcType="ARRAY" mode="OUT"

               typeHandler="EmployeeTableTypeHandlerCallback"/>

  </parameterMap>

  

  <procedure id="findEmployeesTbl_1" parameterMap="parameters4ab">

    <![CDATA[

     { call 

         declare 

           l_tbl employee_tbl; 

         begin 

           l_tbl := find_employees_1(?); 

           ? := l_tbl; 

         end 

     }

    ]]>

  </procedure>


Mime
View raw message