How do you write multi level fetch joins?

24 views
Skip to first unread message

Oddgeir B

unread,
Nov 15, 2018, 10:53:47 AM11/15/18
to Jinq
I have a query that I want to rewrite to use jinq.

SELECT a
INNER JOIN FETCH a.bs AS b
INNER JOIN FETCH b.cs AS c


I tried to do:
..streamAll(session, A.class)
.joinFetch(a -> JinqStream.from(a.getBs()) 
                         .join(b -> JinqStream.from(b.getCs() )
                )

This did not work...

Is it possible? If so, how?

I am currently using jinq-hibernate-legacy version 1.8.19 since I could not get 1.8.24 to work with Hibernate 5.1.

Jinq

unread,
Nov 15, 2018, 11:09:13 AM11/15/18
to Jinq
It never occurred to me that you could chain JOIN FETCH like that. Does Hibernate even support that? 

Actually, now that I think about it, I did play with alternate syntaxes for join fetch in the past, and I might have chosen this syntax specifically because it prevents people from chaining join fetches for some reason. 

In any case, if it doesn't work, then it isn't supported.

Oddgeir B

unread,
Nov 16, 2018, 3:19:27 AM11/16/18
to Jinq
Yes, Hibernate supports it. We use it a lot.

Reply all
Reply to author
Forward
0 new messages