It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Passing Date as parameter in SQL (Hibernate) where clause Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Passing Date as parameter in SQL (Hibernate) where clause" Watch "Passing Date as parameter in SQL (Hibernate) where clause" New topic
Author

Passing Date as parameter in SQL (Hibernate) where clause

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 176
Hi,

I have the code below where I am querying my database based on some parameters and one of them is a date field where I am passing in a java util Date...



In the debug console I can see this come out as follows...



In the DB the value of the Settlement Date field is just "2013-01-27" but as you can see I am passing "Sun Jan 27 00:00:00 EST 2013". Could this be the reason why it is not finding the record? And if so how do I make it to pick it up? All the other fields of my query are present in the DB record.

Thanks in advance for any help.
Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 176
Hi,

I was able to resolve this by casting java util Date to java sql Date.

Thanks.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Passing Date as parameter in SQL (Hibernate) where clause
 
Similar Threads
Http Status 404 Error
Error While deploying EAR application
Problem with date
Hibernate date in criteria
Hibernate & Date