Reputation: 555
The following line of code works perfectly when tested with string
criteria.add(Restrictions.eq("name", "John"));
However when i test it with Date it returns error This is line of code that returns error
criteria.add(Restrictions.eq(currentDate,dd));
This is how i am getting currentDate
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
String currentDate=dateFormat.format(cal.getTime());
I printed currentDate and dd and following is output in console along with the error
Current Date:2014-02-17 dd:2014-02-16
JKInsrException:->could not resolve property: 2014-02-17 of: com.java.JKInsr.Contact
Upvotes: 0
Views: 767
Reputation: 394
Restrictions.eq() takes a property-name as first argument, not a value or object.
You should do it like this:
Restrictions.eq("myDate", dd)
Make sure your Contact class has the myDate-Attribute.
Upvotes: 3