Difference between FetchType LAZY and EAGER in Java Persistence API?

后端 未结 15 994
鱼传尺愫
鱼传尺愫 2020-11-22 08:08

I am a newbie to Java Persistence API and Hibernate.

What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API?

15条回答
  •  无人及你
    2020-11-22 09:04

    The main difference between the two types of fetching is a moment when data gets loaded into a memory.
    I have attached 2 photos to help you understand this.

    Eager fetch

    Lazy fetch

提交回复
热议问题