Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when we make fetch="join" and lazy="true" in hibernate

If we use fetching strategy as "join", a single join query is fired (combining parent and children through one join query) and the default behavior is equivalent to lazy="false". This means that all the children records would be fetched for the parent at once. But, what would be the behavior, if we mark lazy="true"? Since the join query is single, what would be lazily fetched?

like image 999
Gaurav Avatar asked Oct 29 '13 07:10

Gaurav


1 Answers

FetchMode Join overrides the lazy property. It will simple be ignored. Should you be interested in a detailed explanation about Fetchmodes, take a look here. The article describes the Hibernate fetchmodes and the output which they produce.

like image 187
Hans Maes Avatar answered Oct 31 '22 12:10

Hans Maes