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

How to apply Sort instead of QSort #38

Closed
dirkluijk opened this issue Sep 8, 2021 · 1 comment · Fixed by #39
Closed

How to apply Sort instead of QSort #38

dirkluijk opened this issue Sep 8, 2021 · 1 comment · Fixed by #39

Comments

@dirkluijk
Copy link
Contributor

dirkluijk commented Sep 8, 2021

Hi, small question.

I am able to apply sorting using QSort successfully, for example:

import com.bol.foo.QFoo.foo

fooRepository.findAll(
  foo.someField.eq("bar"),
  QPageRequest.of(2, 25, foo.otherField.asc())
)

This works perfect, and it uses the generated mapping from QFoo.foo.

However, when I use Springs default Sort, things get messy:

fooRepository.findAll(
  foo.someField.eq("bar"),
  PageRequest.of(2, 25, Sort.by(Sort.Order.asc("otherField")))
)

In this case, it seems it uses an incorrect database column field otherField instead of other_field (I use the default naming from Spring JDBC).

Note: the reason I want to use the default Sort from Spring is because it integrates better into Spring Web (e.g. automatic argument resolving, configuration, annotating default sorts, etc) and because the QSort from QueryDSL includes a lot of sensitive stuff that get's included in the JSON serialisation (I might want to report that over there).

@dirkluijk
Copy link
Contributor Author

See #39 for a possible fix

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

Successfully merging a pull request may close this issue.

1 participant