Hibernate level cache, level two cache, and query cache

Source: Internet
Author: User

First -level cache (must exist)
the session has a shared cache that accompanies the session's life cycle existence and extinction:
1. The LOAD query entity supports first-level caching
2. The GET query entity object also supports
3. The entity object saved by Save is cached in the first level cache

4. Clear evict clears session cache
5. Save huge data, every 20 data, General flush execute the SQL to persist the data and then clear cache, prevent memory overflow, save put last.

6. Iterate using a first-level cache (Query entity objects in Creatquery list uses a first-level cache, query object entity properties are not used)

Level Two cache
process-level caches or sessionfactory caches can be shared by the session, accompanied by sessionfactory existence and extinction.


Query Cache
Cache only the normal attribute result set, the entity object caches only the ID

Life cycle: Ends when the table associated with the query changes. Not related to level two cache. Need to display enabled, Query.setcacheable (true) and only work on list, iterator does not work, it does not use query caching.


Crawl strategy
1. Query crawl fetch=join. The foreign key associated with the object is also taken out, a SQL, will invalidate the lazy, improve efficiency, can be configured or native SQL

2. Subselect Sub-query policy




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.