CodeForLife
CodeForLife

Reputation: 89

GUIDEWIRE : How to display the the query builder result in UI?

I am using query builder to return number of search result from the database table. Now I would like to display the result in the UI by only first three rows. How can I achieve this?

Upvotes: 0

Views: 585

Answers (1)

Carlos Duque
Carlos Duque

Reputation: 512

QueryAPI is lazy, when .toList(), .toTypedArray(), .toCollection(), .where(), etc occurs all resultset is retrieved (eager).

I recommend you to use this:

var limit = 3
var rs = Query.make(entity.XXX)...select()
rs.setPageSize(limit)
var paginatedRS = com.google.common.collect.Iterables.limit(rs,limit)

setPageSize method specifies how many rows will be fetch "by page"

limit method make a new iterator that have only the first (limit) rows

Upvotes: 1

Related Questions