IBATIS does not insert TIME component

Friday, March 26, 2010

I found that IBATIS was not inserting the TIME component of the date field into the Oracle database.

I had the following configuration in the SqlMap.

Under resultMap, the column was mapped as given below -

<result column="DATE_OF_CREATION" jdbcType="TIMESTAMP" property="dateOfCreation"/>

The insert statement was as below -



 

<insert id="person_insert" parameterClass="Person">
insert into PERSON (NAME, DOB)
values (#name:VARCHAR#, #dateOfCreation:DATE#)
</insert>


 
After a lot of debugging, I found that the problem was because of using "DATE" as the jdbcType. The JDBC "DATE" data type stores only the year, month and day.
 
I changed "DATE" to "TIMESTAMP" in both the places and it started working.