iBATIS - Defining 'javaType' and 'jdbcType'

删除回忆录丶 提交于 2019-12-06 02:49:32

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/4907055/ibatis-defining-javatype-and-jdbctype

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!