[Migration Article] two articles (Ajax refresh problem, learning from Hibernate)

Source: Internet
Author: User

The locally cached webpage has an impact on Ajax.

I used to define a small content page as the carrier of the returned content to use Ajax.
During development, you often encounter an inexplicable problem: it is clear that nothing is wrong, but the results still have problems or are the same as before.
I have never figured out what is going on. Fortunately, I accidentally ran a hit and cleared the local cache of IE when I encountered such a problem. The problem was solved.
Think about it because although the content page returned by the Ajax request is only embedded in the main page during the presentation, ie still saves a copy as a separate page, so how do you modify the source code? The client still generates the returned content based on the previous page.
I'm going to add
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
As a temporary solution, ie clears the page cache every time it is disabled.
In future studies, we will no longer rely on web pages as the carrier of returned content and seek other methods.

 

[] There is actually a simple solution to this problem, that is, every time an Ajax request is submitted, it is OK to bring a parameter value that changes each time, for example, {_: + new date} This set of parameters ensures that the latest content is obtained every time Ajax is used.

 

Learn some scattered knowledge from Hibernate

Vo and Po
After vo is saved, it becomes a po and enters the hibernate persistent cache.
The Return Value of the Hibernate query method is also Po.
After the session is closed, the PO becomes vo.
When session. Flush () is used, all changed pods are automatically searched to update the database.
Therefore, in the view layer with opensessioninviewfilter, changing the Bo value will directly affect the database, which is a good explanation of the strange problem I encountered before.

When is data obtained from the persistent layer?
The query conditions are obtained directly from the database, such as the find method.
Specify the primary key ID to obtain a single piece of data or iterate the iterate. The corresponding data is first searched from the persistent layer and then searched in the database.
(In this case, persistence plays almost no role in our project ...)

Optimistic lock and pessimistic lock
The pessimistic lock is specified using the setlockmode () method. The data obtained from the query cannot be modified before the query statement.

The optimistic lock adds an attribute optimistic-lock = "version" to the specified class in the mapping configuration"
Add a field <version column = "version" name = "version" type = "Java. Lang. Integer"/>
The lock method is like the control of the version library.

Setfetchsize () and setmaxresult ()
In the list returned by setmaxresult (), only a specified number of results are returned.
The setfetchsize () method is as follows: for one-time queries to the database, only a specified number of results are obtained. When these results are traversed and more results are required, hibernate then reads a specified amount of new data into the database.
Based on this, I understand that setmaxresult is mainly used for paging, while setfetchsize () is based on performance considerations.

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.