开发者

iBATIS - Defining 'javaType' and 'jdbcType'

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=开发者_JAVA技巧"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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜