3

How to implement Left or right outer join in QueryDsl. A simple example is helpful.

Pரதீப்
  • 91,748
  • 19
  • 131
  • 172
user1456650
  • 41
  • 1
  • 6
  • Post your data or your query. Will be helpful to give you an exact solution – Jim Macaulay Oct 07 '16 at 16:06
  • 1
    http://stackoverflow.com/questions/28849713/querydsl-left-join-with-additional-conditions-in-on http://stackoverflow.com/questions/29836826/querydsl-how-to-make-left-join-by-column – Pரதீப் Oct 07 '16 at 16:07
  • Thanks, Prdp. 1) JPAQuery query = queryUtil.createJpaQuery() .from(t1).leftJoin(t1.t2, t2 ).on(t2.a.eq(t1.t2.a), how to change it to left outer join? 2) if 2 tables have no relationship, can they be jointed in QueryDsl? – user1456650 Oct 07 '16 at 16:17
  • @user1456650 - I don't know anything about `QueryDsl`. Did a google search and copy pasted results here – Pரதீப் Oct 07 '16 at 16:24
  • I did google search, all are about left join in QueryDsl, none is about outer join – user1456650 Oct 07 '16 at 16:27
  • According to the documentation, `leftJoin` and `rightJoin` are actually outer joins. The naming is quite confusing in my opinion. – techfly Dec 21 '18 at 09:05

1 Answers1

1

You should use leftJoin method for that sake. E.g.:

queryUtil
    .createJpaQuery()
    .from(t1)
    .leftJoin(t1.t2, t2)
    .fetchJoin()
    .where(t2.a.eq(t1.t2.a))
    .fetchAll()
nndru
  • 2,057
  • 21
  • 16
  • But why? Why is there no "outerJoin" method in QDSL? – Casey Mar 31 '17 at 13:29
  • Please, refer to query dsl documentation: http://www.querydsl.com/static/querydsl/3.2.2/reference/html/ch02.html, paragraph '2.1.7. Using joins'. – nndru Jun 10 '17 at 10:51