Best practice for fetch

Hi, sorry i didn’t find an answer to this one. What is best practice for fetch type in Hibernate associations? Should we set eager or lazy based on the amount of data we have in our application? I ask because if I set to lazy I am afraid there will be n+1 problem, but if its eager it maybe loading unnecessary data, so should this decision be based on our own unique cases in our application? Is there a way to set a global fetch type?


You can find some guidelines in the 5.6 Proxies and lazy fetching chapter of Hibernate’s introduction guide, notice also the linked resources about association fetching.

These are general recommendations; based on your specific use case, you might want to fine tune each case depending on the data structure and your application’s needs.

Thanks, this helps a lot.