The difference between lazy loading in hibernate, get method and load side difference method

Source: Internet
Author: User

Lazy loading is the default way of associating objects in Hibernate, and lazy loading will first query the object and get the object's ID.

SQL statements are actually written when they are actually being used for data.

Lazy loading is a valid load period when the session is opened, so we must keep the session open when we want to use lazy loading.

Urgent loading is the direct use of SQL statements to access the database, but speed relative to lazy loading faster.

The Get () method emits an SQL statement to the database as soon as it executes.

The load () method is similar to lazy loading and only emits SQL statements if the entity's properties are actually used;

Also, when the database does not have a query, the method returns a Null,load method and runs out of the exception objectnotfoundexception.

The difference between lazy loading in hibernate, get method and load side difference method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.