• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbctype for enum in parameterMap's parameter in IBATIS

 
vishnu neerukattu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to update a table in mysql using ibatis and I have to update an enum value and I have given jdbctype for that property as varchar.
when I am executing in I am getting an error as below.can someone help me in this regard.
Please find the code below
here strModRole is declared as enum in the procedure.

<parameterMap id="addParameters" class="java.util.Map" >
<parameter property="strDrs" jdbcType="FLOAT" javaType="java.lang.Float" mode="IN"/>
<parameter property="strUts" jdbcType="FLOAT" javaType="java.lang.Float" mode="IN"/>
<parameter property="strRout" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
<parameter property="strSer" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
<parameter property="strModId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
<parameter property="strModRole" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
</parameterMap>

<procedure id="test" parameterMap="addParameters">
{call temp.sp_SET_values(?,?,?,?,?,?)}
 
Dhananjay Patkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishnu,
You need to provide a type handler in case of custom types such as enums
You need to write a class which will implement
com.ibatis.sqlmap.client.extensions.TypeHandlerCallback
and provide implementation for
public Object getResult(ResultGetter getter)throws SQLException
public void setParameter(ParameterSetter setter, Object parameter)throws SQLException

Here's a simple example of a boolean handler that uses "Yes" and "No":
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic