Hibernate's principle architecture, five core interfaces, three state transitions for Hibernate objects, transaction management

Source: Internet
Author: User
One: The Principle of Architecture
25 Major Core interfacesHibernate has a total of 5 core interfaces: Session, Sessionfactory, transactio N, query, and Configurat ion. These 5 core interfaces will be used in any development. Through these interfaces, you can not only access persistent objects, but also enable transaction control. The following five core interfaces are described separately.

· Session Interface:
The session interface is responsible for performing crud operations on persisted objects (the task of crud is to complete the communication with the database, including many common SQL statements. )。 However, it is important to note that the session object is non-thread-safe. At the same time, Hibernate's session differs from the HttpSession in JSP applications. When the term "session" is used, it is actually referring to the session in Hibernate, and later the Httpsesion object is called the user session.

· Sessionfactory Interface:
The Sessionfactroy interface is responsible for initializing hibernate. It acts as a proxy for the data storage source and is responsible for creating session objects. The factory model is used here. It is important to note that Sessionfactory is not lightweight, because in general, a project typically requires only one sessionfactory, and when you need to manipulate multiple databases, you can specify a sessionfactory for each database.

· Configuration Interface:
The configuration interface is responsible for configuring and starting hibernate to create the Sessionfactory object. During Hibernate startup, the instance of the configuration class first locates the map document location, reads the configuration, and then creates the Sessionfactory object.

· Transaction interface:
The transaction interface is responsible for transaction-related operations. It is optional, and developers can also design their own underlying transaction-processing code.

· Query and Criteria Interface:
The query and criteria interfaces are responsible for executing various database queries. It can be expressed in either the HQL language or the SQL statement.
three state transitions for three hibernate objects
Four Transaction ManagementStart transaction management, because the session is not thread-safe, so it can be setautocommit (false); ... commit (), and so on.

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.