-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with timestamp field.
PostPosted: Mon Oct 30, 2006 12:07 pm 
Newbie

Joined: Mon Oct 30, 2006 11:26 am
Posts: 2
I'm working with Hibernate 3.0.5 and Mysql 5.0, I have the next problem, I'm trying of get the diff of two timestamp:

select sum(d.firstTimestamp - d.secondTimestamp) from dates d where d.user.id = ? and d.secondTimestamp >= ? and s.firstTimestamp < ? and s.secondTimestamp is not null;

The error:

Hibernate operation: could not execute query; SQL state [S1009]; error code [0]; Cannot convert value '70161.0' from column 1 to TIMESTAMP.; nested exception is java.sql.SQLException: Cannot convert value '70161.0' from column 1 to TIMESTAMP.
java.sql.SQLException: Cannot convert value '70161.0' from column 1 to TIMESTAMP.

Thanks for you help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 2:48 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
70161.0, a value in one of your columns, isn't matching what hibernate expects a java.sql.Timestamp value to be

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 3:57 pm 
Newbie

Joined: Mon Oct 30, 2006 11:26 am
Posts: 2
Thanks for you help, but the problem is that I do not know like use datediff in hql for mysql. The query work in postgres but not in mysql.


select sum(d.firstTimestamp - d.secondTimestamp) from dates d where d.user.id = ? and d.secondTimestamp >= ? and s.firstTimestamp < ? and s.secondTimestamp is not null;


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