The conversion from int to TIMESTAMP is unsupported

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The conversion from int to TIMESTAMP is unsupported

laredotornado
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)
Reply | Threaded
Open this post in threaded view
|

Re: The conversion from int to TIMESTAMP is unsupported

Kimgisa
Could you replace java property of date field to java.sql.Date?

On 10월5일, 오전5시50분, laredotornado <[hidden email]> 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 ...
>
>         <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.executeQueryWith Callback(MappedStatement.java:
> 201)
>         at
> com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForL ist(MappedStatement.java:
> 139)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe cutorDelegate.java:
> 567)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe cutorDelegate.java:
> 541)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI mpl.java:
> 118)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI mpl.java:
> 122)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImp l.java:
> 98)
>         at
> com.myco.persistence.ibatis.OptinDaoImpl.getOptins(OptinDaoImpl.java:
> 50)
>         at com.myco.config.Web.getOptinMap(Web.java:112)
Reply | Threaded
Open this post in threaded view
|

Re: The conversion from int to TIMESTAMP is unsupported

Clinton Begin
Administrator
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 <[hidden email]>
Could you replace java property of date field to java.sql.Date?

On 10월5일, 오전5시50분, laredotornado <[hidden email]> 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 ...
>
>         <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.executeQueryWith Callback(MappedStatement.java:
> 201)
>         at
> com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForL ist(MappedStatement.java:
> 139)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe cutorDelegate.java:
> 567)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe cutorDelegate.java:
> 541)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI mpl.java:
> 118)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI mpl.java:
> 122)
>         at
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImp l.java:
> 98)
>         at
> com.myco.persistence.ibatis.OptinDaoImpl.getOptins(OptinDaoImpl.java:
> 50)
>         at com.myco.config.Web.getOptinMap(Web.java:112)

Reply | Threaded
Open this post in threaded view
|

Re: The conversion from int to TIMESTAMP is unsupported

laredotornado
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 <[hidden email]> 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 <[hidden email]>
>
> > Could you replace java property of date field to java.sql.Date?
>
> > On 10월5일, 오전5시50분, laredotornado <[hidden email]> 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 ...
>
> > >         <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.executeQueryWith
> > Callback(MappedStatement.java:
> > > 201)
> > >         at
>
> > com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForL
> > ist(MappedStatement.java:
> > > 139)
> > >         at
>
> > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe
> > cutorDelegate.java:
> > > 567)
> > >         at
>
> > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExe
> > cutorDelegate.java:
> > > 541)
> > >         at
>
> > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI
> > mpl.java:
> > > 118)
> > >         at
>
> > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionI
> > mpl.java:
> > > 122)
> > >         at
>
> > com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImp
> > l.java:
> > > 98)
> > >         at
> > > com.myco.persistence.ibatis.OptinDaoImpl.getOptins(OptinDaoImpl.java:
> > > 50)
> > >         at com.myco.config.Web.getOptinMap(Web.java:112)