Using Hibernate's query cache skillfully

Source: Internet
Author: User

It is well known that Hibernate is an excellent persistence layer framework, especially his data caching mechanism attracts a lot of developers. For the use of different data query with the level two cache, the use of the level two cache is not the same, such as the list and iterator method, the list of two cache only write not read, and iterator can make good use of the two level cache, but the iterator method has a very bad problem, Is the problem that n+1 queries occur. How to use both the level two cache and do not produce n+1 queries, the following is a good way to introduce, that is, the use of Hibernate query caching.

Why is it called skillfully use, because improper use query cache, still will appear n+1 query problem.

Unfortunately, I spent a long time writing a long article, who knows just because accidentally pressed backspace (perhaps the cursor is not in the editing area), causing the page to jump (back), and then try to go through the forward button back to the edit page, it is too late, back is returned, But so many words have just been written, has vanished ...

Really want to%@# (*#&^

So let's just cut it short, that is, when configuring the query cache, set the number of query caches multiplied by the number of per-page displays not greater than the number of class caches for that cache table. May be more awkward, but the meaning is fully contained in the inside, we have time to slowly understand it. Do not understand the words don't blame me, blame this damned csdn blog not for us to consider thoughtful it.

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.