As per my understanding As soon as i mention fetchtype as eager, i am left only with join fetch strategy but when i mention as fetchtype as lazyloading, i have other three options i.e select,batch-size and subselect.Agreed? Now if i look at code snippet in one my legacy project , it mentioned fetch type as eager and fetch strategy as select which contracdicts each other. Right?
Another query is i do not see batch-size option when i write FetchMode. and do control + space in eclipse though i see other three fetch strategies?
Hibernate collections have fetch type and fetch mode settings.
Fetch type specifies when elements of collection are retrieved, and fetch mode specifies how Hibernate retrieves them.
So, FetchMode.SELECT and FetchMode.SUBSELECT are legal with both FetchType.EAGER andFetchType.LAZY. The difference is that with FetchType.EAGER an additional select query is executed immediately, whereas with FetchType.LAZY it's executed after the first access to the collection.
FetchMode.JOIN, however, doesn't make sense with FetchType.LAZY.
Batch size is an additional optimization for FetchMode.SELECT, so that it should be configured by its own annotation (@BatchSize) and has nothing to do with FetchMode enumeration itself.