ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gwyn Evans <gwyn.ev...@gmail.com>
Subject Re: Oracle date type mapping issue
Date Thu, 08 Nov 2007 08:43:37 GMT
Hi Thorsten,

Hmm - the first is what I use, i.e.

	CREATE TABLE XX_LOG
	(
	    ID        INTEGER  NOT NULL,
	    T         DATE DEFAULT SYSDATE NOT NULL,
	    ...
	) ;
and
        <resultMap id="LogResult" class="c.z.t.w.m.model.Log">
            <result column="ID" property="id" jdbcType="INTEGER" />
            <result column="T" property="timestamp" jdbcType="TIMESTAMP" />
            ...
        </resultMap>

and 
    <select id="selectByExample" resultMap="LogResult" ...>
            select L.ID, L.T, ... from XX_LOG L WHERE ...
    </select>
and
    public class Log implements Serializable {
	private Long id;
	private Date timestamp;
       public Long getId() { return id; }
       public void setId(Long id) { this.id = id; }
       public Date getTimestamp() { return timestamp; }
       public void setTimestamp(Date timestamp) { this.timestamp = timestamp; }
 	...
    }


/Gwyn

On 08 November 2007, 8:04:16 AM, Thorsten Elfert wrote:
>

well, this does not work as well. I tried: 

<result property="validFrom" column="VALID_FROM" jdbcType="TIMESTAMP"/> 

and I tried: 

<result property="validFrom" column="VALID_FROM" jdbcType="TIMESTAMP" javaType="java.sql.Timestamp"/>


the time gets truncated all the time. 

Thorsten 
________________________________________ 

Hi Thorsten, 

On 07 November 2007, 3:58:47 PM, Thorsten Elfert wrote: 

> 

Hi, 

I use Oracle 9i, JDK 5 and the latest iBatis Release. Whenever I read a date object out of
oracle and map it into a java.util.Date attribute the time gets truncated. I tried already
to set explicitly the javaType as java.util.Date or java.sql.Timestamp and the jdbcType as
DATE in the sql-map but it does not solve the problem. What is the correct way to map a java.util.Date
to the Oracle Date Object ? (In the database the date and time gets stored correctly) 



Try using the jdbcType as TIMESTAMP as the SQL DATE type only contains a date! 
See "Dates and Times" here - http://www.oreilly.com/catalog/jentnut2/chapter/ch02.html. 

-- 
/Gwyn . 



Mime
View raw message