Fetch = fetchtype in hibernate Lazy lazy loading failure handling method

For this lazy loading problem, the final approach is to use a hibernate support class provided by spring. Its main meaning is to open the hibernate session when initiating a page request and keep the session all the time, so as to prolong the life cycle of Hibernate session until the end of the request. Specifically, it is implemented through a filter. Then, if we want to use hibernate lazy loading feature and extend the life cycle of the session to bring the data to the page display (through the action layer), we have to add the following configuration in the web.xml file:

Note: 1) opensessioninviewfilter is the filter name, * Action means to intercept all actions, or/*

2) non web page requests (such as scheduled tasks) can be processed in the following way (hibernate. Initialize (object proxy) method is forced to load, which is equivalent to dynamically changing to lazy = false)

summary

The above is the fetch = fetchtype in Hibernate introduced by Xiaobian Lazy lazy loading failure handling method, I hope to help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>