Difference between FetchType LAZY and EAGER in Java Persistence API?

后端 未结 15 1290
鱼传尺愫
鱼传尺愫 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 08:50

    As per my knowledge both type of fetch depends your requirement.

    FetchType.LAZY is on demand (i.e. when we required the data).

    FetchType.EAGER is immediate (i.e. before our requirement comes we are unnecessarily fetching the record)

提交回复
热议问题