« Return to Thread: Reusing criteria prev. builded

Reusing criteria prev. builded

by Lucas Teixeira :: Rate this Message:

Reply to Author | View in Thread

Hello all,

I'm  building a complex query using gorm criteria, and I'll have to use it 2 times, first one using the "list" method to retrieve its results and then I'll use it again with the 'get' method to count the results.
I can't get the result list size to get number of returned rows cause I'm cutting it with max and offset params.

So, I'm building the same criteria twice... First time this way:

listaUnidades = criteria.list(max:formData.qtParam, offset:firstResult) {
            and {
                 ... //all my conditionals
            }
        }

and the second time this way:

qtdeResultados = criteria.get() {
            and {
                 ... //all the same conditionals
            }
        }


I'd like to know if I can build the criteria closure outside it and just reuse the same reference instead of making this way I'm doing right now.

Thanks!

[]s,



Lucas Frare Teixeira .·.
- lucastex@...
- lucastex.com.br
- blog.lucastex.com
- twitter.com/lucastex

 « Return to Thread: Reusing criteria prev. builded