Hibernate version: 3.2.5
Name and version of the database you are using: Oracle 10g
Is there a way to bind a value in a Criteria query?
I would like to perform something like the following:
Date user_date = <user supplied date>
Criteria criteria = Criteria.createCriteria( "cats" );
criteria.setProjection( Projections.sqlProjection( "abs( create_date - ? )" ) );
criteria.setDate( user_date );
List result = criteria.list();
The code above is an example of the issue I am having with criteria queries. There is no "setDate()" method on Criteria (although I wish there was).
I want result to contain create_dates, a per row value, relative from user_date, a value supplied from the user.
- I have a strong preference for bind values over embedding values directly in SQL expressions.
- I would prefer to not use HQL.
Any input? Is there another way to do this? Is it possible to bind values with Criteria queries??
- Aaron
|