Results 1 to 3 of 3

Thread: Issue while mapping Oracle User defined data type with Java POJO using Ibatis

  1. #1
    Join Date
    Feb 2012
    Posts
    23

    Default Issue while mapping Oracle User defined data type with Java POJO using Ibatis

    Hi,

    I am trying to map my Java POJO with customized ORACLE datatype and I am facing issues. Below are the details. Please help.

    My Oracle defined data type :

    TYPE myOBJ AS OBJECT (
    code varchar2(2), desc VARCHAR2(10), price NUMBER(12,2) );

    Oracle Procedure :

    create or replace
    PROCEDURE myProc(
    PARAM1 IN myOBJ,
    PARAM2 OUT NUMBER ,
    PARAM3 OUT VARCHAR )
    AS
    ........
    END myProc;

    My

  2. #2
    Join Date
    Feb 2012
    Posts
    23

    Default

    My JAVA POJO :

    public class myPOJO {
    private String code;
    private String desc;
    private Integer price;

    //getters & setters
    .....
    .....

    SQLmap proc call configuration

    <typeAlias alias="myPOJOTypeHandler"
    type="abc.xyz.myPOJOTypeHandler" />

    <parameterMap class="java.util.HashMap" id="insertmyPOJOParameterMap">
    <parameter property="PARAM1" mode="IN" typeHandler="abc.xyz.myPOJOTypeHandler" javaType="abc.xyz.myPOJO" />
    <parameter property="PARAM2" mode="OUT" javaType="java.lang.Integer" jdbcType="NUMERIC" />
    <parameter property="PARAM3" mode="OUT" javaType="java.lang.String" jdbcType="VARCHAR" />
    </parameterMap>

    <resultMap class="java.util.HashMap" id="insertmyPOJOResultMap">
    <result property="PARAM2" javaType="java.lang.Integer"
    jdbcType="NUMERIC" />
    <result property="PARAM3" javaType="java.lang.String" jdbcType="VARCHAR" />
    </resultMap>

    <procedure id="insertmyPOJO" parameterMap="insertmyPOJOParameterMap"
    resultMap="insertmyPOJOResultMap">
    {call myProc(?,?,?)}
    </procedure>

  3. #3
    Join Date
    Feb 2012
    Posts
    23

    Default

    public class myPOJOTypeHandler implements TypeHandlerCallback {

    @Override
    public Object getResult(ResultGetter resultGetter) throws SQLException {
    System.out.println("In getResult >>>>>>>>>");
    return null;
    }

    @Override
    public void setParameter(ParameterSetter parameterSetter, Object object)
    throws SQLException {

    PreparedStatement ps = parameterSetter.getPreparedStatement();
    myPOJO routeResponse = (myPOJO) object;

    Ques : How do I map my java object with Oracle Object? Am I missing anything in my configuration?
    }

    System.out.println("In setParameter <<<<<<<<<<<<<<<<<<<<<<<<<"+ps.getParameterMetaData ().getParameterCount());

    }

    @Override
    public Object valueOf(String str) {
    System.out.println("In valueOf!!!!!!!!!!!!");
    return null;
    }

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •