Hibernate has five core interfaces, namely: Session Transaction Query sessionfactoryconfiguration

Source: Internet
Author: User

Session interface:

The session interface session interface is one of the most important interfaces for hibernate developers. In hibernate, however, the instantiated session is a lightweight class, and creating and destroying it does not consume a lot of resources. This is really important in the actual project, because in the client program, the session object may be created and destroyed continuously, if the session overhead is too large, it will adversely affect the system. But the session object is non-thread safe, so in your design it is better to have a thread that creates only one session object. Session can be seen as a middle interface between data connection and transaction management. We can think of the session as a buffer of persistent objects, hibernate detects changes to these persistent objects, and refreshes the database in a timely manner. We sometimes call the session a persistent Layer manager because it contains some persistent layer-related operations, such as storing persistent objects to the database, and getting them from the database. It is important to note that Hibernate's session differs from the HttpSession in JSP applications. When we use the term session, we refer to the session in Hibernate, and we will later call the Httpsesion object 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.

Transaction Interface

The transaction interface is responsible for transaction-related operations , generally occurring in the deletion and deletions of Hib ernate, but people using Hibernate generally use spring to manage transactions.

Query interface

Query is responsible for executing various database queries. It can be expressed in either the HQL language or the SQL statement. its return value is generally LiSt. Need to convert yourself.

Configuration Interface:

The configuration object is used to configure and root start hibernate. Hibernate applications use configuration instances to specify the location of the object-relational map file or dynamically configure Hibernate properties, and then create the Sessionfactory instance. We can view the source code of the configuration, and its configure () method is implemented like this:

Hibernate has five core interfaces, namely: Session Transaction Query sessionfactoryconfiguration

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.