Announcement Announcement Module
Collapse
No announcement yet.
Issue while mapping Oracle User defined data type with Java POJO using Ibatis Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment


    • #3
      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;
      }

      }

      Comment

      Working...
      X