ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Shelley" <12gaugeme...@gmail.com>
Subject Re: Problem Timestamp insert and retriev
Date Mon, 17 Mar 2008 08:25:22 GMT
Should "dateOfBird" be a timestamp?  Normally, timestamp is DB generated
with "CURRENT_TIMESTAMP" as the default value (and On Update
Current_Timestamp optionally enabled).  You shouldn't need to SET this value
if you're insistent on it being a timestamp.  Otherwise, it should be a
Datetime datatype in the DB, "timestamp" in the jdbctype of the resultmap,
and your model would have a matching member variable of "java.util.Date"
datatype.  If it has to be a timestamp, it'd essentially be the same types.

-Ryan

On Mon, Mar 17, 2008 at 1:00 AM, dimitriBarzagli <
dimitri_barzagli@virgilio.it> wrote:

>
> Hi,
>
> I'm developing a web application by IBatis framework to manage database. I
> have a problem about insert and retrieve Timestamp value.
> I use Mysql 5.0 for database and I create a table USER with TIMESTAMP type
> for the DATE_OF_BIRD element. I create Java Bean User with dateOfBird
> member
> by java.sql.Timestamp.
> When I try to insert a new User by the IBatis insert() method the value in
> the database is always 0000-00-00 00:00, but I would it's different value.
> When I try a retrieve by queryForObject() method, the value for dateOfBird
> in UserBean is null.
> Below my user.xml:
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <!DOCTYPE sqlMap
>    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
>    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
>
> <sqlMap namespace="User">
>
>  <!-- Select with no parameters using the result map for Account class.
> -->
>  <select id="selectUser" resultClass="User">
>                SELECT U.ID_UTENTE as idUtente,
>                           U.USERID as userId,
>                           U.PASSWORD as password,
>                           U.COGNOME as cognome,
>                           U.NOME as nome,
>                       U.DATE_OF_BIRD as dateOfBird,
>                       U.PRIMA_PASSWORD as firstPassword,
>                       U.ID_PROFILO as idProfile,
>                       U.EMAIL as email,
>                       U.USER_ACTIVE as userActive
>                FROM USER U
>                WHERE ID_UTENTE = #value#
>  </select>
>  <update id="insertUser" parameterClass="User">
>        INSERT INTO USER (USERID, PASSWORD, COGNOME, NOME, DATE_OF_BIRD,
> PRIMA_PASSWORD, ID_PROFILO, EMAIL, USER_ACTIVE)
>        VALUES (#userId#, #password#, #cognome#, #nome#, #dateOfBird#,
> #firstPassword#, #idProfile#, #email#, 'Y');
>  </update>
> </sqlMap>
>
> Someone can I help me?
>
> Thank you.
>
> --
> View this message in context:
> http://www.nabble.com/Problem-Timestamp-insert-and-retriev-tp16089864p16089864.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message