The difference between load () and get () in Hibernate, the difference between lazy loading and eager loading

Source: Internet
Author: User
Tags one table

The difference between load () and get () in Hibernate:

Get (): Is the direct manipulation of the database, the ID gets the data encapsulated object, if there is no data to return null;

Load (): query in the session cache first, if the cache does not exist, then delay the query from the database, do not find a matching record, will throw a objectnotfoundexception. A no session exception is thrown if the session is closed in a deferred query

The difference between lazy loading and eager loading in hibernate:

Eager loading: querying the current table and other associated tables together, select has too many statements and requires frequent access to the database, which can affect the performance of the query. "Manytoone default eager Load"

Lazy load: queries only the table you are working on, does not automatically query the associated tables, and is efficient "onetomany default lazy Loading" with only one table in operation

The difference between load () and get () in Hibernate, the difference between lazy loading and eager loading

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.