Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support expressions around subqueries in order by for PaginatedCriteriaBuilder #38

Closed
Mobe91 opened this issue Aug 5, 2014 · 1 comment
Assignees
Milestone

Comments

@Mobe91
Copy link
Contributor

Mobe91 commented Aug 5, 2014

We must support the following for id queries (we do not support this in the CriteriaBuilder or SubqueryBuilder):
e.g. selectSubquery("a").fromblabla.end().page(0,1).orderBySubquery("MAX(a)", true, false)

For the id query we must extract the wrapping expression for the order by clause and apply it to the corresponding select alias (which must correspond to a subquery). E.g we then have

SELECT id, MAX(SELECT bla FROM bla) AS a ORDER BY a

@Mobe91 Mobe91 self-assigned this Aug 5, 2014
@beikov
Copy link
Member

beikov commented Aug 5, 2014

Also add the following to the PaginatedCriteriaBuilder interface
SubqueryInitiator orderBySubquery(String expression, String alias, boolean ascending, boolean nullsFirst)

with a behavior so that the following will be possible:

orderBySubquery("MAX(s)", "s", true, false)
  .from(Person.class)
   // somecode
  .end()

results in the following idQuery

SELECT ..., MAX(SELECT ... FROM Person) AS any_alias FROM ... ORDER BY any_alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants