Hi Marcel,
2016-06-07 10:16 GMT+02:00 Marcel Overdijk <[email protected]>:
> Regarding the mutability of the Query would it be possible to clone a
> (base) Query?
>
Right now, no. jOOQ query parts are not cloneable.
> I'm creating some utility methods like:
>
> protected <T> Page<T> queryForPage(SelectJoinStep baseQuery, Pageable
> pageable,
> RowMapper<T> rowMapper) {
>
>
> From that baseQuery I want to create a count query and paged query (note
> windowing functions is not supported in my database).
>
> When I first construct the count query like:
>
> jooq
> .selectCount()
> .from(baseQuery);
>
>
>
>
> and then paged query like:
>
> baseQuery
> .orderBy(toOrderBy(pageable))
> .limit(pageable.getPageSize())
> .offset(pageable.getOffset());
>
>
> I think it should be ok as I believe the selectCount() will not alter the
> baseQuery.
>
That's correct, but you have to make sure you execute the first query
before you modify the base query for the latter case.
> But in case I create the paged query before the count query the baseQuery
> was already altered which might be error prone.
>
Yes.
I don't think you're saving a lot of CPU cycles this way. Personally, I'd
just rather not recycle these objects.
Lukas
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.