File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate Select - Criteria with a Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Select - Criteria with a Date" Watch "Hibernate Select - Criteria with a Date" New topic

Hibernate Select - Criteria with a Date

Chris Montgomery
Ranch Hand

Joined: Jan 14, 2004
Posts: 141
Hibernate appears to be using a 'fasttime' value?? for my date in its WHERE clause and doesn't return rows that it should from the database:

Here's a 50K foot view of my Doman and DAO objects along with the SQL output.
I'm using annotations for hibernate and have set the temporal type for my date objects to DATE (I've tried all three)



My variables output shows that the start and end date 'criterion' are pointing to the correct property name, but when it comes to the actual value, cdate is null and fasttTme is 1304139600000.

Unfortunately, my log4j.xml isn't responding to TRACE, so I am not able to see the actual parameters I'm hoping I'm still on the right track.

Here's what Hibernate has for a query:

when I use the values from fastTime values, the rows do not come back.
when I use the 'yyyy-MM-dd' equivalent of the fast time values, the query does work.

This is how I was able to confirm the equivalent from the fastTime:

Hoping for a little nudge in the right direction.


Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 661

Just a thought. Can we not annotate and override the getter methods of dates to return values of desired type?

If you are not laughing at yourself, then you just didn't get the joke.
Chris Montgomery
Ranch Hand

Joined: Jan 14, 2004
Posts: 141
Many apologies folks. False alarm. the dates weren't even the issue. it was a separate criteria that was the culprit.

For some reason I keep having to relearn the lesson of 'elimination'.
Start removing various factors to weed out the cause.

I agree. Here's the link:
subject: Hibernate Select - Criteria with a Date
It's not a secret anymore!