What's the advantage of load() vs get() in Hibernate?

前端 未结 10 2736
感情败类
感情败类 2020-12-02 04:58

Can anyone tell me what\'s the advantage of load() vs get() in Hibernate?

10条回答
  •  情话喂你
    2020-12-02 05:07

    The performance issues is also major difference between get and load method.

    The get() method fetches data as soon as it’s executed while the load() method returns a proxy object and fetches only data when object properties is required. So that the load() method gets better performance because it support lazy loading. Whe should use the load() method only when we know data exists because it throws exception when data is not found. In case we want to make sure data exists we should use the get() method.

    In short, you should understand the differential in between, and decide which method is best fix in your application.

    I found this differences on the tutorial Difference between get and load method in Hibernate

提交回复
热议问题