what is the difference in specifying lazy = \"true\"
and using fetch = \"select\" or \"join\"
? which one is preferred over the other ?
FetchMode : It defines how
hibernate (using which strategy, e.g. Join, SubQuery etc) will fetch data from database.
FetchType : It defines whether
hibernate will fetch the data or not.
FetchMode
isn't only applicable with FetchType.EAGER
. The rules are as follows: a) if you don't specify FetchMode
, the default is JOIN
and FetchType
works normal, b) if you specify FetchMode.JOIN
explicitly, FetchType
is ignored and a query is always eager, c) if you specify FetchMode.SELECT
or FetchMode.SUBSELECT
, FetchType.Type
works normal