Hibernate version: 2.1
I am trying to do something in the Crieria API that works great in HQL
Here is the HQL version:
"from Product prod where prod.year = currentyear()"
currentyear() is an Oracle function that returns the current year
Now, I want to move this query into the Criteria API. Here's my attempt that doesn't work:
.createCriteria(getSession(),Product.class)
.add(Expression.eq("year","currentyear()"))
.list();
This doesn't work because hibernate translates this into "... year = ?" and current year doesn't get evaluated as a function.
Can someone please tell me how to accomplish this? I'm sure someone else has tried to do this before.
Thanks
|