Hibernate Tip: Using LEFT JOIN and FETCH JOIN in a CriteriaQuery

preview_player
Показать описание

In todays tip video, I will show you how to use LEFT JOINs and FETCH JOINs in a CriteriaQuery.

JPA’s different JOIN clauses are one of the essential parts of JPQL and the Criteria API. They tell Hibernate which database tables it shall join in the generated SQL query and how it shall do that.
Unfortunately, the Criteria API is not as easy to use as most of us would prefer. That’s especially the case if you want to use a JOIN FETCH clause or select multiple entities.

If you like this video, please give me your thumbs up and share it with your friends and co-workers.

Like my channel? Subscribe!

Join the free Member Library:

Want to connect with me?

#JPA #hibernatetips #joincolumn
Рекомендации по теме
Комментарии
Автор

Hello sir, i added a join statement but my eclipse show Not found errors at Author_, how can i fix it

minhduccao
Автор

I want to do left join with more one conditions. Is there any example or docs ?

nagendirank
Автор

I have 2 entities:

Table1 : embeddedId -> number, code
Table2: embeddedId -> number, code
want to left join table2 on table1 using criteriaquery.

I am getting error: cannot join basic attibute, tried alomost everything,

nidhiyadav
Автор

Select emp e1 where (e1.id, e1.version) IN (select e2.id, max(e2.version) from e2 group by e2.id

Could you plz explain how can we do this using criteria query ?

rajendramalya