Announcement Announcement Module
Collapse
No announcement yet.
querying by Date using Criteria Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • querying by Date using Criteria

    Hello,

    I have a table in the DB that has a date as a primary key (called cobdate). i need to select data from a certain date and i'm having problems to do it. I'm using Criteria to do my query. My property cobdate is mapped as a java.util.Date to a column in a table in an Oracle 9 database. I'm converting the input string from the user, that it's like '20051102' into a java.util.Date using the following:

    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMdd");
    java.text.ParsePosition pos = new java.text.ParsePosition(0);
    mycob = formatter.parse(cobdate, pos);

    And then I query like this:

    Criteria crit = session.createCriteria(j.getClass());

    crit.setMaxResults(100);
    crit.add(Expression.ilike("reportingCob", mycob));


    What am i doing wrong that i get an error?

    Help is much appreciated,
    Thanks
    M
Working...
X