Grails: Get list and count with criteria

def list = {
    params.max = Math.min(params.max ? params.int('max') : 10, 100)
    def providerLocationInstanceList = params.providerId ?
    ProviderLocation.createCriteria().list(params) { 
        eq("provider.id", params.providerId.toLong())
    } : ProviderLocation.list(params)

    [providerLocationInstanceList: providerLocationInstanceList,
        providerLocationInstanceTotal: providerLocationInstanceList.totalCount]
}

2 thoughts on “Grails: Get list and count with criteria

  1. I like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my site dbekeddffcdd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s