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

Comments

Projects
None yet
4 participants
@timowest
Member

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Dec 9, 2013

Member

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());
Member

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());
@olivergierke

This comment has been minimized.

Show comment
Hide comment
@olivergierke

olivergierke Dec 9, 2013

+1 (probably not unexpected ;) )

+1 (probably not unexpected ;) )

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Dec 12, 2013

Member

Released in 3.3.0.BETA2

Member

timowest commented Dec 12, 2013

Released in 3.3.0.BETA2

@timowest timowest closed this Dec 12, 2013

@panga

This comment has been minimized.

Show comment
Hide comment
@panga

panga Dec 13, 2013

Contributor

Thank you Timo! You are the man.

Contributor

panga commented Dec 13, 2013

Thank you Timo! You are the man.

@johnjaylward

This comment has been minimized.

Show comment
Hide comment
@johnjaylward

johnjaylward 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.

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