Get and Load methods for session in Hibernate

Source: Internet
Author: User

Both session and get are data used to get objects, but there are some differences in use.

1. Get in use queries the first-level cache, but if there is no hit, the SQL statement is submitted to the database for re-querying.

2. When load is in use, the first level cache is queried, and if there is no hit, a level two cache is queried, and if there is still no hit, the query is submitted back to the database for execution.

3. Load supports lazy loading, but get not.

4. If get does not query the result, a null value is returned. If the load does not query the result, the exception information objectnotfoundexception will be thrown.

In Hibernate, the session level is usually the first level cache, the sessionfactory level is a level two cache, where the level two cache needs to be opened extra.

Get and Load methods for session in Hibernate

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.