Chapter II IOC
1. When launching the IOC container through Beanfactory, the bean in the configuration file is not initialized and the initialization action occurs at the first call. For a singleton bean, beanfactory caches the instance and fetches the bean directly from the cache the second time it is called.
2. Contextapplication instantiates all the singleton beans when the application context is initialized, so the startup time is longer than beanfactory, but there is no first call to punish.
3, WebApplication is specially prepared for the web, from WebApplication can get ServletContext reference, ServletContext is the context of the Web application. The initialization of WebApplication is different from the above two factory because it requires a ServletContext instance, so you must have a Web container in order to complete the startup work.
Spring provides two ways to initialize the Webapplicationcontext,servletcontext listener, the self-starting servlet. Only web containers of Servlet2.3 and above support ServletContext Listener mode initialization Webapplicationcontext. Specific how to configure, with the following text to add .....
4, the container, configuration information, application implementation of the relationship between, personally think this picture is very good to explain the problem
5. Use the Util namespace to configure the bean for the collection class; Simplify configuration with P-namespace
6. Scope of Bean
Fifth Chapter Hibernate
1. HIBERNATE4 recommends using a thread-bound OST currentsession, no longer using hibernatetemplate.
2. Delayed load problem.
Hibernate allows lazy loading of associated properties, objects, but must ensure that deferred loading is limited to the same amount of Hibernate Session. If the service layer returns a domain object that has the lazy load feature enabled to the Web layer, when the Web tier accesses data that requires lazy loading, the hibernate session that loads the domain object is closed, causing the access exception to delay loading the data.
Spring specifically provides a opensessionviewfilter filter that allows you to bind each request process to a hibernatesession, even if the initial transaction is complete, and you can do lazy loading on the Web tier.
The Opensessionviewfilter filter binds the hibernate session to the request thread, which is automatically detected by spring's transaction manager. Therefore, the opensessionviewfilter is suitable for the service layer environment that uses Hibernatetransactionmanger or Jtatransactionmanger for transaction management, and can also be used in data operations that are not read-only transactions.
To enable this filter, you must configure it in Web. xml:
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param> <param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
"Spring3.0 is so simple"--study Note 1