Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparing dates

 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I am brand new to Hibernate, HQL and using Oracle. I have written my first HQL and am seeing something strange which I hope is a "newbie" mistake that will be obvious to you all.
I wrote my HQL, and it does run fine according to the logs, but returns no rows. I cut and paste the SQL that the HQL was transformed to (I have that logged) and paste it into my Oracle SQL Developer window, I plug in the parameters, and the query runs and returns 1 row, as I would expect.
I have narrowed the problem down to the date compare.
First I tried this as part of my HQL:


I used the dateValue returned by calender.getTime(), after setting the calendar to today's date, with the hours/min/sec all set to zero as follows


Though I do have a row in my table that has a date value of today, no rows are returned when I run the query through the java app. Why would the SQL I cut and paste from the log return a row when I paste this value in for the date parameter : '26-Aug-09 12:00:00AM' , but when run via the java app, return no row?

Thanks for any help!
Kim
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My coworker just helped me to find the problem.

Turns out I am using a tool called "Oracle SQL Developer" which I used to manually set the date to make a row that would be returned by my query. I was not aware that this tool did not change the actual date in the table, I guess it just makes a "working" version for the time I am using the tool. I am still confused by this but I guess my HQL was fine, and there really was not a proper row in the database for it to return.

This one hurt my brain ! Gotta start using the SQL prompt from a DOS window.

Thanks anyway everyone!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic