-->
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.  [ 2 posts ] 
Author Message
 Post subject: MySQL Datetime vs. Timestamp
PostPosted: Tue Jan 18, 2005 11:20 pm 
Newbie

Joined: Tue Jan 18, 2005 11:13 pm
Posts: 19
Thanks in advance for the help.

I'm using Hibernate 2.1 with MySQL 4.1 and I'm having a problem with losing precision when trying to store a java.util.Calendar object. Theorectically, I should be able to maintain precision if it's stored as a SQL Timestamp. However, when Hibernate creates the tables, a sql datetime is used instead. Looking at the MySQL Dialect, this is how it's implemented. Does anyone know why this is?

To fix my problem, I've attempted to override this mapping by using the sql-type attribute on the column element, but that doesn't appear to work. Here is the relevant portion of the mapping file that I'm using:

<property name="createdDate" access="field">
<column name="created_date" sql-type="TIMESTAMP" not-null="true"/>
</property>

Am I using this properly? If so and if this is not a solution to my problem, does anyone have any other suggestions for maitaning the time precision?

Thank you, again.

Scott


Top
 Profile  
 
 Post subject: Re: MySQL Datetime vs. Timestamp
PostPosted: Wed Jan 19, 2005 9:45 pm 
Newbie

Joined: Tue Jan 18, 2005 11:13 pm
Posts: 19
Problem somewhat solved. It turns out that the MySQL timestamp type doesn't store milliseconds, either. So, I'll have to a find another way to deal with this problem.

[quote="sgoldstein"]Thanks in advance for the help.

I'm using Hibernate 2.1 with MySQL 4.1 and I'm having a problem with losing precision when trying to store a java.util.Calendar object. Theorectically, I should be able to maintain precision if it's stored as a SQL Timestamp. However, when Hibernate creates the tables, a sql datetime is used instead. Looking at the MySQL Dialect, this is how it's implemented. Does anyone know why this is?

To fix my problem, I've attempted to override this mapping by using the sql-type attribute on the column element, but that doesn't appear to work. Here is the relevant portion of the mapping file that I'm using:

<property name="createdDate" access="field">
<column name="created_date" sql-type="TIMESTAMP" not-null="true"/>
</property>

Am I using this properly? If so and if this is not a solution to my problem, does anyone have any other suggestions for maitaning the time precision?

Thank you, again.

Scott[/quote]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.