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

Generic querydsl orderBy dynamic path generation with left joins #582

Closed
timowest opened this issue Dec 4, 2013 · 5 comments
Closed

Generic querydsl orderBy dynamic path generation with left joins #582

timowest opened this issue Dec 4, 2013 · 5 comments
Milestone

Comments

@timowest
Copy link
Member

@timowest timowest commented Dec 4, 2013

Generic orderBy using deep paths and left joins is not yet supported in Querydsl JPA http://stackoverflow.com/questions/20287194/generic-querydsl-orderby-dynamic-path-generation-with-left-joins

The inner joins caused by implicit join usage in the order by path should be replaced with left joins.

@timowest
Copy link
Member Author

@timowest timowest commented Dec 9, 2013

Change suggestion:
If the orderBy argument contains a path that uses at least three elements then the path will be replaced with a joined path of length two where the parent is replaced with a left joined version or an already joined alias.

e.g.

example 1

query.from(user)
  .orderBy(user.department.name.asc());

=>

query.from(user)
    .leftJoin(user.department, department)
    .orderBy(department.name.asc());

example 2

query.from(user)
  .orderBy(user.department.company.name.asc())

=>

query.from(user)
  .leftJoin(user.department, department)
  .leftJoin(department.company, company)
  .orderBy(company.name.asc());

example 3
if a join replacement is already available

query.from(user)
    .innerJoin(user.department, department)
    .orderBy(user.department.name.asc());

=>

query.from(user)
    .innerJoin(user.department, department)
    .orderBy(department.name.asc());
@odrotbohm
Copy link

@odrotbohm odrotbohm commented Dec 9, 2013

+1 (probably not unexpected ;) )

@timowest
Copy link
Member Author

@timowest timowest commented Dec 12, 2013

Released in 3.3.0.BETA2

@timowest timowest closed this Dec 12, 2013
@panga
Copy link
Contributor

@panga panga commented Dec 13, 2013

Thank you Timo! You are the man.

@johnjaylward
Copy link

@johnjaylward johnjaylward commented Dec 13, 2013

Wow, this is awesome! I didn't even realize this was requested. I've wanted this since I started using hibernate 7 years ago.

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

Successfully merging a pull request may close this issue.

None yet
4 participants