Spring, hibernate, struts interview questions, hibernatestruts

Source: Internet
Author: User

Spring, hibernate, struts interview questions, hibernatestruts

1. Is Action thread-safe? If there is no way to ensure the thread security of Action? If yes, explain the reason
No
Declare local variables, or expand RequestProcessor to create an Action each time, or use scope = "prototype" in spring to manage

2. MVC: analyze how struts implements MVC.
M: JavaBean or composed of EJB components or pojo
C: Action to implement
V: A group of JSP files and their tags.

3. Role of several key objects in struts (Role of several key objects)
Action: controller class, ActionForm: form object, DynaValidatorForm: dynamic form, ActonMapping: information about the action node in the configuration file ......

4. Introduce the concepts of AOP and IOC and how to apply them in spring.
AOP: Aspect-Oriented Programming, ioc: dependency injection; declarative and programmatic transactions are positive and common

5. What data query methods does Hibernate use?
Hql query, SQL query, and conditional Query

6. Differences between load () and get ()
Hibernate considers the load method to exist in the database and can safely use the agent to delay loading. By default, load supports delayed loading and queries the database only when other attribute data in the object is used, however, if the record does not exist in the Database, only the exception ObjectNotFoundEcception can be thrown. The load method throwing exception refers to throwing an exception when the data of this object does not exist in the database, instead of creating this object. Since the session cache is a very cheap resource for hibernate, we will first check the session cache during load to see if the object corresponding to this id exists, create a proxy if it does not exist (query level-1 Cache during load, and create a proxy if it does not exist ). Get () now finds the first-level cache. If it does not, it searches for the second-level cache. If it does not, it searches for the database. If it does not, it returns null. For the get method, hibernate must obtain the real data, otherwise, null is returned.

7. Talk about hibernate's delayed loading and openSessionInView
Delayed loading should be within the session range and re-loaded when used; opensessioninview writes
Filter to open and close the session. This means that the session is always on during a request, ensuring the delay.
This premise is loaded in the session.

8. How can spring transactions be performed? Let's talk about the isolation level and Propagation Behavior of spring transactions.
Declare transactions and programming transactions
Isolation level:
-DEFAULT: use the DEFAULT database isolation level
-READ_UNCOMMITTED: there will be dirty reads, and repeated reads and Phantom reads are not allowed.
-READ_COMMITTED: Repeated read and phantom read will appear.
-REPEATABLE_READ: phantom read will appear.
-SERIALIZABLE is the safest, but the most expensive, with extremely serious performance impact.
And propagation line:
-If REQUIRED has a transaction, it is integrated into the transaction. If it does not exist, the transaction is created.
-If SUPPORTS has a transaction, it is integrated into the transaction. If it does not exist, no transaction is created.
-If a MANDATORY transaction exists, the transaction is merged. If the transaction does not exist, an exception is thrown.
-REQUIRES_NEW: always creates new transactions.
-NOT_SUPPORTED: if a transaction exists, the transaction is suspended and non-transaction operations are continuously performed.
-NEVER always executes non-transactions. If the current transaction exists, an exception is thrown.
-NESTED embedded transactions

9. Differences between update () and saveOrUpdate () in Hibernate.
From hibernate instructions:
SaveOrUpdate () Does the following:
If the object is already persistent in this session, do not do anything
If another object associated with this session has the same persistent identifier (identifier), an exception is thrown.
If the object does not have the identifier attribute, call save ()
If the object's persistent identifier (identifier) indicates that it is a new instantiated object, it calls save ()
If an object contains version information (via or) and the value of the version attribute indicates that it is a new instantiated object, save () It. Otherwise, update () is the object.
10. Spring provides good support for a variety of ORM frameworks. It briefly describes how to use Hibernate in Spring and integrates transaction management.
GetHiberanteTemplate provides methods such as save, update, delete, and find.
To put it simply: If a declarative transaction is configured, the transaction will
Automatically loaded
If no transaction is configured, the above operations will not be actually synchronized to the database, unless the hibernate
Autocommit = true
8. How can spring transactions be performed? Let's talk about the isolation level and Propagation Behavior of spring transactions.
Spring transactions are divided into declarative transactions and programming transactions. spring provides a transaction interface.
The PaltformTractionManager interface implements different implementations for different transactions and processes hibernate transactions.
Implementation of HIbernateTractionManager, JdbcTractionManager for JDBC,
Cetcetractionmanager and JdoTractionManager. The platformTractionManager interface provides three
Methods to obtain the transaction, commit, and rollback methods.

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.