The conversion from int to TIMESTAMP is unsupported

707 views
Skip to first unread message

laredotornado

unread,
Oct 4, 2010, 4:50:02 PM10/4/10
to mybatis-user
Hi,

I'm using iBatis 2.3. I have this map …

<resultMap id="Optin" class="com.myco.domain.Optin">
<result property="id" column="optin_id" />
<result property="type" column="optin_type" />
<result property="orientation"
column="optin_orientation" />
<result property="date" column="optin_date"
nullValue="" />
</resultMap>

I'm getting the below error when I run this query …

<select id="getAllOptins" resultMap="Optin">
SELECT o.*, null as optin_date FROM dbo.optins o
</select>

Anyone know what I'm doing wrong? The Java field is a java.util.Date
for which my date column is mapping. Thanks, - Dave

--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The
conversion from int to TIMESTAMP is unsupported.
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:
201)
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:
139)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:
567)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:
541)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:
118)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:
122)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:
98)
at
com.myco.persistence.ibatis.OptinDaoImpl.getOptins(OptinDaoImpl.java:
50)
at com.myco.config.Web.getOptinMap(Web.java:112)

Kimgisa

unread,
Oct 4, 2010, 8:46:33 PM10/4/10
to mybatis-user
Could you replace java property of date field to java.sql.Date?

On 10월5일, 오전5시50분, laredotornado <laredotorn...@zipmail.com> wrote:
> Hi,
>
> I'm using iBatis 2.3. I have this map ...
>
> <resultMap id="Optin" class="com.myco.domain.Optin">
> <result property="id" column="optin_id" />
> <result property="type" column="optin_type" />
> <result property="orientation"
> column="optin_orientation" />
> <result property="date" column="optin_date"
> nullValue="" />
> </resultMap>
>
> I'm getting the below error when I run this query ...

Clinton Begin

unread,
Oct 4, 2010, 9:38:49 PM10/4/10
to mybati...@googlegroups.com
Eww... don't change it to a java.sql.Date... :-)  

It is odd though... but try explicitly setting the jdbcType to TIMESTAMP.  

Otherwise it's likely a driver issue... which driver/DB are you using?  

Worst case scenario, you need a custom type handler.

Cheers,
Clinton

2010/10/4 Kimgisa <magu...@gmail.com>

laredotornado

unread,
Oct 5, 2010, 9:43:18 AM10/5/10
to mybatis-user
The problem has something ot do with the way I'm mapping the "null"
result. If I change my query to

<select id="getAllOptins" resultMap="Optin">
SELECT o.*, GETDATE() optin_date FROM dbo.optins o
</select>

everything works fine (before I had "null optin_date"). So my
question, is, how do I construct the query and/or result mapping such
that I can put a null in my Java member field.

Thanks, - Dave


On Oct 4, 8:38 pm, Clinton Begin <clinton.be...@gmail.com> wrote:
> Eww... don't change it to a java.sql.Date... :-)
>
> It is odd though... but try explicitly setting the jdbcType to TIMESTAMP.
>
> Otherwise it's likely a driver issue... which driver/DB are you using?
>
> Worst case scenario, you need a custom type handler.
>
> Cheers,
> Clinton
>
> 2010/10/4 Kimgisa <magud...@gmail.com>
Reply all
Reply to author
Forward
0 new messages