-->
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: Hibernate retrieves no result while sql stmt executes fine
PostPosted: Wed Aug 09, 2006 6:44 am 
Newbie

Joined: Wed Aug 09, 2006 6:30 am
Posts: 2
Hibernate version:
3.1.3

We have a MediaObject class and want to search using time associated with the instances. However, the search retrives no result (while there is legal data in the db). The MediaObject class works fine anywhere else, so we assume it's not its problem.

No exception is thrown. When we copied the sql statement into the mysql query browser and execute it with real time params, we actually got results. We didn't try it with direct JDBC prepared statements, but we suspect it will work too. We ran into a similar problem before and managed to got *around* (instead of over) that one, and the JDBC prepared statement worked fine there while hibernate failed to retrive any results.

The HQL query string:
select searched.id from MediaObject searched where searched.time between ? and ?

Then bind params using:
setDate(0, new Date(0)); setDate(1, new Date());

The database we use:
MySQL 5.0.something

The generated SQL:
select mediaobjec0_.id as id6_ from medobjintr mediaobjec0_ where mediaobjec0_.time between ? and ? limit ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 8:20 am 
Newbie

Joined: Wed Aug 09, 2006 6:30 am
Posts: 2
problem fixed changing the data type of MediaObject.time from timestamp to date. Is it that the timestamp cannot be searched? It seems quite impossible.


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.