-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: java.util.Date losing milliseconds
PostPosted: Wed Sep 21, 2005 2:02 pm 
Newbie

Joined: Mon Aug 08, 2005 8:33 am
Posts: 7
I am using Hibernate 3.

I have a column which is a java.util.Date and I have specified its type as Timestamp in the mapping file.

<property name="Timestamp" type="timestamp" not-null="true"/>

There are 2 things I do not understand:

1. Generated database column

When I generate the database table, it creates a mysql column of type datetime not timestamp. The hibernal sql dialect I am using is:
org.hibernate.dialect.MySQLDialect.

2. Milliseconds have disappeared

When I save a timestamp to the database, the milliseconds are being lost:

For example a timestamp before it is written to the database looks like this: 21-09-2005 18:55:42:343. WHen I get it back it looks like this: 21-09-2005 18:55:42:00.

What is causing this?

James


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 7:56 pm 
Newbie

Joined: Thu Sep 08, 2005 9:27 am
Posts: 10
Hi James,
I am using Hibernate 2 but I believe this doesn't have to do anything with the problem.
I think the datetime type in MySql doesn't hold the millis value. The mapping you mention is correct and it works fine, but I hadn't payed attention to this detail before.

_________________
Pablo N. Alvarez
Austral University
Argentina


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 3:57 am 
Newbie

Joined: Mon Aug 08, 2005 8:33 am
Posts: 7
Hi Pablo

Thanks for the reply.

yes it looks as though Mysql does not have datetime type that can store milliseconds.

There is a question about this problem on the mysql lists:

http://lists.mysql.org/java/8216

James


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 10:11 am 
Newbie

Joined: Thu Sep 08, 2005 9:27 am
Posts: 10
Good to know.

Don't forget to rate!

Bye

_________________
Pablo N. Alvarez
Austral University
Argentina


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.