You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by jaybytez <ja...@gmail.com> on 2006/08/03 23:02:53 UTC
When to use jdbcType or javaType
I have been using both jdbcType and javaType everytime when creating a
parameterMap or resultMap. Is this necessary? I am using standard drivers
for Oracle 9i. I read the documentation, but was not totally clear if there
are performance issues or scalability issues by not doing this? I am just
trying to figure out whether its always necessary so I can simplify the sql
map files for developers and so they don't have to add unnecessary
configuration. Is it only necessary when a value maybe null or using a type
handler?
<resultMap id="zipCodeRegion" class="providerZipCodeTO">
<result property="zipCode" column="zrl_zip_code" jdbcType="VARCHAR"
javaType="string"/>
<result property="region" column="zrl_region_cd" jdbcType="VARCHAR"
javaType="string"/>
<result property="state" column="zrl_state" jdbcType="CHAR"
javaType="string"/>
<result property="tprZipCode" column="zrl_tpr_zip_flag" jdbcType="CHAR"
javaType="string"/>
</resultMap>
<parameterMap id="loadLogParameters" class="java.util.Map">
<parameter property="startTime" jdbcType="TIMESTAMP"
javaType="java.sql.Timestamp"/>
<parameter property="userId" jdbcType="VARCHAR" javaType="string"/>
</parameterMap>
Thanks,
Jay
--
View this message in context: http://www.nabble.com/When-to-use-jdbcType-or-javaType-tf2048046.html#a5640671
Sent from the iBATIS - User - Java forum at Nabble.com.
Re: When to use jdbcType or javaType
Posted by Nathan Maves <Na...@Sun.COM>.
I would suggest that you do use the jdbcType attribute. This always
helps with inserting null values into a table.
Nathan
On Aug 3, 2006, at 3:02 PM, jaybytez wrote:
>
> I have been using both jdbcType and javaType everytime when creating a
> parameterMap or resultMap. Is this necessary? I am using standard
> drivers
> for Oracle 9i. I read the documentation, but was not totally clear
> if there
> are performance issues or scalability issues by not doing this? I
> am just
> trying to figure out whether its always necessary so I can simplify
> the sql
> map files for developers and so they don't have to add unnecessary
> configuration. Is it only necessary when a value maybe null or
> using a type
> handler?
>
> <resultMap id="zipCodeRegion" class="providerZipCodeTO">
> <result property="zipCode" column="zrl_zip_code"
> jdbcType="VARCHAR"
> javaType="string"/>
> <result property="region" column="zrl_region_cd"
> jdbcType="VARCHAR"
> javaType="string"/>
> <result property="state" column="zrl_state" jdbcType="CHAR"
> javaType="string"/>
> <result property="tprZipCode" column="zrl_tpr_zip_flag"
> jdbcType="CHAR"
> javaType="string"/>
> </resultMap>
>
> <parameterMap id="loadLogParameters" class="java.util.Map">
> <parameter property="startTime" jdbcType="TIMESTAMP"
> javaType="java.sql.Timestamp"/>
> <parameter property="userId" jdbcType="VARCHAR"
> javaType="string"/>
> </parameterMap>
>
> Thanks,
>
> Jay
> --
> View this message in context: http://www.nabble.com/When-to-use-
> jdbcType-or-javaType-tf2048046.html#a5640671
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
Re: When to use jdbcType or javaType
Posted by Nathan Maves <na...@gmail.com>.
I think you will find that using javaType and jdbcType on result maps will
give you a performance boost.
On 8/10/06, jaybytez <ja...@gmail.com> wrote:
>
>
> Thanks for the reply and sorry for the vague questions.
>
> Just trying to learn the most I can about jdbcType and javaType as I am
> the
> architect implementing iBatis into our framework. I want the config files
> to be as simple for the developers as possible without missing required
> fields.
>
> So I am always using jdbcType in parameter maps and javaTypes only when
> using Date/Timestamp or needing a typeHandler. The information I got from
> the previous posts...and that makes sense.
>
> On result maps, I include javaType only when a custom typeHandler is
> required. I was just more unsure if jdbcType is required or necessary on
> resultMaps...and if so why?
>
> Thanks!
>
> jay
> --
> View this message in context:
> http://www.nabble.com/When-to-use-jdbcType-or-javaType-tf2048046.html#a5748022
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
>
Re: When to use jdbcType or javaType
Posted by jaybytez <ja...@gmail.com>.
Thanks for the reply and sorry for the vague questions.
Just trying to learn the most I can about jdbcType and javaType as I am the
architect implementing iBatis into our framework. I want the config files
to be as simple for the developers as possible without missing required
fields.
So I am always using jdbcType in parameter maps and javaTypes only when
using Date/Timestamp or needing a typeHandler. The information I got from
the previous posts...and that makes sense.
On result maps, I include javaType only when a custom typeHandler is
required. I was just more unsure if jdbcType is required or necessary on
resultMaps...and if so why?
Thanks!
jay
--
View this message in context: http://www.nabble.com/When-to-use-jdbcType-or-javaType-tf2048046.html#a5748022
Sent from the iBATIS - User - Java forum at Nabble.com.
Re: When to use jdbcType or javaType
Posted by Nathan Maves <Na...@Sun.COM>.
Quite the vague question....
The short answer is no. ibatis will do its best to figure out how
what to use. It can only help to specify the jdbcType.
Nathan
On Aug 10, 2006, at 9:38 AM, jaybytez wrote:
>
> Do you need jdbcType on both parameterMap and resultMap?
>
> thanks!
>
> jay
> --
> View this message in context: http://www.nabble.com/When-to-use-
> jdbcType-or-javaType-tf2048046.html#a5746814
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
Re: When to use jdbcType or javaType
Posted by jaybytez <ja...@gmail.com>.
Do you need jdbcType on both parameterMap and resultMap?
thanks!
jay
--
View this message in context: http://www.nabble.com/When-to-use-jdbcType-or-javaType-tf2048046.html#a5746814
Sent from the iBATIS - User - Java forum at Nabble.com.
Re: When to use jdbcType or javaType
Posted by Jeff Butler <je...@gmail.com>.
In my experience setting the jdbcType is important in parameter maps, either
explicit or inline, in these cases:
1. If the value can be nullable - because it allows iBATIS to call a type
specific setNull() function. Some drivers (cough DB2 cough) cannot deal
with an unknown jdbc type on setNull().
2. When you're mapping java.util.Date to TIMESTAMP, DATE, and TIME columns
(this is a good practice - best to avoid the java.sql versions if possible)
Other than that I don't think you really need these values unless you're
doing type handlers or trying to override iBATIS' default TypeHandler
calculation.
Jeff Butler
On 8/3/06, jaybytez <ja...@gmail.com> wrote:
>
>
> I have been using both jdbcType and javaType everytime when creating a
> parameterMap or resultMap. Is this necessary? I am using standard
> drivers
> for Oracle 9i. I read the documentation, but was not totally clear if
> there
> are performance issues or scalability issues by not doing this? I am just
> trying to figure out whether its always necessary so I can simplify the
> sql
> map files for developers and so they don't have to add unnecessary
> configuration. Is it only necessary when a value maybe null or using a
> type
> handler?
>
> <resultMap id="zipCodeRegion" class="providerZipCodeTO">
> <result property="zipCode" column="zrl_zip_code" jdbcType="VARCHAR"
> javaType="string"/>
> <result property="region" column="zrl_region_cd" jdbcType="VARCHAR"
> javaType="string"/>
> <result property="state" column="zrl_state" jdbcType="CHAR"
> javaType="string"/>
> <result property="tprZipCode" column="zrl_tpr_zip_flag" jdbcType="CHAR"
> javaType="string"/>
> </resultMap>
>
> <parameterMap id="loadLogParameters" class="java.util.Map">
> <parameter property="startTime" jdbcType="TIMESTAMP"
> javaType="java.sql.Timestamp"/>
> <parameter property="userId" jdbcType="VARCHAR" javaType="string"/>
> </parameterMap>
>
> Thanks,
>
> Jay
> --
> View this message in context:
> http://www.nabble.com/When-to-use-jdbcType-or-javaType-tf2048046.html#a5640671
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
>