Beside this, what is difference between lazy loading and eager loading?
With Eager Loading, all the data is retrieved in a single query, which can then be cached to improve the Application performance. With Eager Loading, we are trading memory consumption for the database round trips. With Lazy Loading, we only retrieve just the amount of data, which we need in a single query.
Furthermore, what is lazy loading in Java? Lazy loading is a concept where we delay the loading of object until the point where we need it. In simple words, Lazy loading is a software design pattern where the initialization of an object occurs only when it is actually needed and not before to preserve simplicity of usage and improve performance.
In respect to this, what is lazy loading and eager loading in spring?
It is called as eager or aggressive loading because of loading all the bean , instance instantiated and initializing at the container start-up only. In the case of lazy loading all the beans will be loaded, instantiated and initialized when the container try to use them by calling getBeans() method.
Should I use lazy loading?
When you SHOULD use lazy load:Most of your images are below the fold, at least a few scroll-clicks from the top of the site. (makes sense not to load images/items that users might not even scroll to) You've got huge images, and no CDN. (saves server resources/bandwidth)