I need to use year() and month() functions in Criteria API to be able
to express a business filter constraint/filter. I have business object
with property Duration (NH compoenent) with DateFrom and DateTo
datetime fields. The user story is like "show me objects with duration
covering september 2009". I didn't found any other solution for
building the query without using year() and month() functions which
are available in HQL. Unfortunately I have to use Criteria API and I
can't find out how to use these functions (or some equivalents) in
Criteria API query. The solution in HQL looks like this:

var year = 2009; //user input
var month = 4; //user input
var ym = year * 100 + month;
var hql = ... :ym between 100 * year(f.Duration.DateFrom) + month
(f.Duration.DateFrom) and 100 * year(f.Duration.DateTo) + month
(f.Duration.DateTo)";

Is it possible to express this HQL condition in Criteria API query?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to