Size of assosiation in Hibernate criteria.

Posted by trnl on Stack Overflow See other posts from Stack Overflow or by trnl
Published on 2010-05-16T14:07:51Z Indexed on 2010/05/16 14:10 UTC
Read the original article Hit count: 198

Hello guys.

I've faced with a problem when querying with Hibernate Criteria in Grails.

Take a look:

def visitors = Client.withCriteria{
          visits{
             use ( TimeCategory ) {between('date',date,date+1.month-1)}
          }
          sizeGe("visits",params.from)
          sizeLe("visits",params.to)
          fetchMode("visits", FM.JOIN)
    };

I need only those clients, which has number of visits in month between from and to bounds.

But now size* restrictions is being applied to all visits. So if client has one visit in this month, and visit in previous month. And if I set from=2, this client will be in result. But it should not be there.

Any help is appreciated.

Thanks, Vova.

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about criteria