Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iBATIS - Defining 'javaType' and 'jdbcType'

Tags:

java

ibatis

While defining the resultMap in iBatis, it provides an option to set the javaType and jdbcType for each property to column mapping.

e.g.

<resultMap id="employee" class="com.mycompany.Employee">
   <result property="firstName" column="first_name" javaType="?" jdbcType="?"/>
</resultMap>

Wanted to know that when we should be defining the javaType and jdbcType? I have seen mapping where it just works without defining these properties and in others we have to define them.

EDIT: See the selected answer below for the above question.

Also, do we have an exhaustive list out of which javaType and jdbcType should be defined?

EDIT: javaType should be one of the well-known types e.g. java.lang.String, java.util.Date and jdbcType should be coming out of java.sql.Types

Thanks in advance!

like image 640
peakit Avatar asked Feb 05 '11 13:02

peakit


1 Answers

For jdbcType the documentation (for iBATIS 3) states:

The JDBC type is only required for nullable columns upon insert, update or delete.

On page 33 in this document is a list of supported JDBC types.

For the javaType attribute it says:

iBATIS can usually figure out the type if you’re mapping to a JavaBean. However, if you are mapping to a HashMap, then you should specify the javaType explicitly to ensure the desired behaviour.

like image 105
Elbonian Avatar answered Sep 20 '22 11:09

Elbonian