I encountered a problem while questioning the hibernate criteria in Grails.
Take a look:
def visitors = Client.withCriteria {visit {usage (timecacher) {between ('date', date, date + 1 month -1) )}} Size (from "Visits", parameter) takes shape ("Visits", Parameters. 2) Fetchoda ("Visits", FM.Join)};
I only need those customers, from to and to between the number of visits in the month < Strong>.
But now the restrictions are being applied on all visits, so if the customers have made a visit this month and are traveling in the last month. And if I set to = 2 , then this client will be in the result. But it should not be there.
// UPD: I do not work on things like sizeGe and take shape .
From my point of view, they should be implemented after the middle restriction, but they are not.
For example:
def client = new customer (); Client.visits.add (new visit (date: '2010-03-16')); Client.visits.add (new visit (date: '2010-05-16')); Client.visits.add (new visit (date: '2010-05-17')); Client.save ();
And then I want to:
- Date = date. From ('yyyy-MM', '2010-05')
- P> Do not return;
But this gives returns, because size << strong> is being applied to all visits, no matter what date it is.// UPD UPD.
I know that smth is still unclear
Any help is appreciated.
Thank you, Vova.
You will need a clause to do this and I found it to add support for it.
In the meanwhile, you should use HQ and write the query manually. If you do not need to change the restrictions of queries based on a few selected areas, then you should always go with HQL, it can be cached.
Comments
Post a Comment