OneToOne LEFT JOIN Issues

213 views
Skip to first unread message

Thiago Corrêa Paim

unread,
Oct 24, 2016, 4:37:46 PM10/24/16
to Jinq
Hi!

I have an @OneToOne relationship in an Object streamed with Jinq Stream.
The problem is that, when fetching a list of that Object, for each one, Hibernate is triggering a separate select to fetch the relationship data instead of using a left join to fech it in one query only.

I don't know if it is a Hibernate issue or a Jinq issue.

Does anybody knows?

Thanks!


Jinq

unread,
Oct 24, 2016, 8:10:10 PM10/24/16
to Jinq
It could be a Hibernate issue. Usually if the the relationship is labeled as being *eagerly loaded*, then Hibernate should be smart enough to figure out how to add a join to a query to suck in the relationship data. But for complex queries, it might be able to figure out how to add the join properly. 

You should use the getDebugQueryString() trick to figure out what query Jinq has created. That will make it easier to determine whether Hibernate should know how to add a join automatically to the query or not.

Thiago Corrêa Paim

unread,
Oct 25, 2016, 9:07:52 AM10/25/16
to Jinq, jinq-...@googlegroups.com
Hi!

This should explain the issue:


Is there any strategy to force Jinq to include this INNER JOIN FETCH in the generated HQL?

Thanks!!

Jinq

unread,
Oct 25, 2016, 11:06:58 AM10/25/16
to Jinq
Yes, Jinq supports joinFetch() operations. They are defined in JPAJinqStream (they aren't defined in JinqStream though. By default, Jinq actually returns you JPAJinqStreams, so you just have to remember not to upcast them to JinqStreams).
Reply all
Reply to author
Forward
0 new messages