Struts, Spring, Hibernate surface examination questions summarized Keywords: struts spring hibernate interview reproduced Address: http://blog.csdn.net/David8631/archive/2008/07/19/2676615.aspx only collection
Hibernate works and why to use?
1. Read and parse the configuration file
2. Read and parse mapping information, create a SessionFactory
3. Open Sesssion
4. Creating Service Transation
5. Persistence operations
6. To commit the transaction
7. Close Session
8. SesstionFactory Close
* To access the database JDBC code that made package greatly simplifies the tedious repetitive data access layer code.
* Hibernate is a JDBC-based persistence framework for the mainstream, is an excellent ORM implementation. He was a high degree of simplification of the coding DAO layer
* Hibernate using the Java reflection mechanism, rather than the byte-code enhancement procedures to achieve transparency.
* Hibernate performance is very good, because it is a lightweight frame. The flexibility of mapping is very good. It supports a variety of relational database, from a variety of one-to-many complex relationships.
Hibernate is how lazy?
* Hibernate2 lazy to achieve: a) physical objects b) Collection (Collection)
* Hibernate3 provides the property lazy loading function of
When the Hibernate query the data when the data does not exist with the memory, when the program actually in operation on the data, the object until the existence and memory, on the realization of a deferred load, he saved the server's memory overhead, thus improving server performance.
Hibernate classes in how to achieve the relationship between? (Such as:-to-many, many to many relationship)
The relationship between class and class is mainly reflected in the relationship between the table and the table to operate, they operate urban object, we process all the forms and classes are mapped together, they are through the configuration file in the many-to -one, one-to-many, many-to-many,
Referring to the next Hibernate's caching mechanism
* Existence of the internal cache in Hibernate is also called a cache belonging to application-level caching things
* 2 cache:
a) Application and Cache
b) Distributed Cache
Conditions: the data will not be a third party changes, the data size within an acceptable range, the data update frequency is low, the same data frequently used by the system, non-critical data
c) the realization of third-party cache
Hibernate query mode
Sql, Criteria, object comptosition
* Property Search
* Parameter query, named parameter query
* Associated with inquiries
* Paging Query
* Statistical Functions
How to Optimize Hibernate?
* Use two-way-to-many association, do not use one-way-to-many
* A flexible one-way-to-many association
* No-one, with many-to-replace
* Configuration object cache, the cache does not use a collection of
* One to many collections using the Bag, many to many collections using the Set
* Derived class using explicit polymorphism
* Table field is less, the table Do not be afraid associated with more than a second-level cache backing
Struts working mechanism? Why should I use Struts?
Struts work flow:
In the web application will be loaded at startup to initialize ActionServlet, ActionServlet from the struts-config.xml file to read configuration information, store them to a variety of configuration object when the ActionServlet receives a client request, will perform the following process.
(1) to retrieve and match the user request ActionMapping instance, if you do not exist, it returns the request path is invalid information;
(2) If the ActionForm instance does not exist, it creates an ActionForm object, save the form data submitted by customers to the ActionForm object;
(3) According to the configuration information to decide whether the need Forms Authentication. If you need to verify, they call the ActionForm's validate () method;
(4) If the ActionForm's validate () method returns null or return an object that does not contain ActionMessage the ActuibErrors, it's a form validation successful;
(5) ActionServlet under ActionMapping mapping information contained in the decision which forwards the request to the Action, the Action, if the corresponding instance does not exist, create the first instance and then call the Action's execute () method;
(6) Action's execute () method returns an ActionForward object, ActionServlet in the client request transmitted to the ActionForward object pointing to the JSP components;
(7) ActionForward object point to JSP component to generate dynamic web pages, returned to the customer;
JSP, Servlet, JavaBean technology appears to us to build powerful enterprise applications systems possible. However, systems built using these technologies is very fan a mess, on top of this, we need a rule, a technical organization up these rules, this is the framework, Struts thus arose.
Struts-based applications developed by the Category 3 components: controller, components, model components, views components
Struts framework is how to validate authentication?
In the struts configuration file to configure the specific error, and then in the FormBean the validate () method of a specific call.
Referring to the next Struts design patterns
MVC pattern: web application will be loaded at startup and initialization ActionServler. When the user submits the form, a configured ActionForm object is created, and was fill in a form corresponding data, ActionServler under the Struts-config.xml file configuration settings determine the need for good form validation, if you need to call the ActionForm's Validate () validated the option to send the request to which Action, if the Action does not exist, ActionServlet will first create the object, then calls the Action's execute () method. Execute () to get data from the ActionForm object to complete the business logic to return an ActionForward object, ActionServlet then forwarded to the client request ActionForward object specified by jsp component, ActionForward object specified by jsp generate dynamic web pages, returned to the client.
Factory (factory mode):
Define a base class === "Achieving the base class methods (sub-class, through different means )===" definition of a factory class (generated sub-class instance)
=== "Developers call the base class method
Proxy (proxy mode)
spring working mechanism and why to use?
1.spring mvc invited all of the requests are submitted to the DispatcherServlet, it will delegate the application system is responsible for other modules responsible for processing requests for real.
2.DispatcherServlet query one or more of the HandlerMapping, find the handle requests Controller.
3.DispatcherServlet requested to submit the request to the target Controller
4.Controller conduct business logic processing, it will return a ModelAndView
5.Dispathcher query one or more of the ViewResolver view resolver, find the ModelAndView object view of the specified object
6. The view object is responsible for rendering returned to the client.
AOP allows developers to create non-behavioral concerns, called crosscutting concerns, and insert them into the application code. After the use of AOP, the public services (such as logging, persistence, transactions, etc.) can be broken down into aspects and applied to domain objects, domain object at the same time does not increase the complexity of the object model.
IOC allowed to create an application environment objects can be constructed, and then to pass these objects to their collaborators. As the word inversion indicated, IOC like the turn of the JNDI. Do not use a bunch of abstract factories, service locators, single element (singleton) and direct construction (straight construction), each object is constructed with its collaborators. Collaboration is therefore an object from the container-managed (collaborator).
Spring Even if an AOP framework, but also an IOC container. Spring the best place is that it will help you replace the object. With the Spring, as long as the use JavaBean properties and configuration files by adding dependencies (collaborative object). Can then be easily replaced when needed collaboration with a similar interface to an object.