This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Comparing dates

 
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!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic