Hibernate database Persistence layer Framework

Source: Internet
Author: User
Tags most popular database

Hibernate is an object-relational mapping solution under the Java language. It is a free, open source software issued using the GNU Wide general Public License. It provides an easy-to-use framework for the mapping of object-oriented domain models to traditional relational databases. Hibernate is also currently the most popular database persistence framework in Java development and is now owned by JBoss.

It is designed to liberate software developers from many of the same data persistence-related programming work. Whether you start with a draft design or a legacy database, developers can use hibernate.

Hibernate is not only responsible for mapping from Java classes to database tables, but also for mapping from Java data types to SQL data types, and also provides an object-oriented query retrieval mechanism for data, which greatly shortens the manual processing of development time on SQL and JDBC.
Hibernate 3.6 JavaDoc

Hibernate 4.1 GA JavaDoc

Hibernate has a total of 6 core interfaces: Session, Sessionfactory, Transaction, Query, criteria, and configuration. These 6 core interfaces will be used in any development. Through these interfaces, you can not only access persistent objects, but also enable transaction control. These 6 core interfaces are described separately below.SessionThe 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 HttpSession object is called the user session.sessionfactoryThe Sessionfactory 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.TransactionThe Transaction interface is an optional API that allows you to opt out of using this interface instead of the underlying transaction code written by Hibernate's designers themselves. The Transaction interface is an abstraction of the actual transaction implementation, which includes JDBC transactions, usertransaction in JTA, and even CORBA transactions. This design is designed to enable developers to use a single transactional interface, allowing their projects to be easily ported between different environments and containers.QueryThe query interface makes it easy to make queries against databases and persistent objects, which can be expressed in two ways: the HQL language or the SQL statement for the local database. Queries are often used to bind query parameters, limit the number of query records, and ultimately perform query operations.CriteriaThe criteria interface is very similar to the query interface, allowing you to create and execute object-oriented, standardized queries. It is important to note that the query interface is also lightweight and cannot be used outside the session.ConfigurationThe purpose of the configuration interface is to configure Hibernate and start it. During Hibernate startup, an instance of the configuration class first locates the location of the mapped document, reads the configuration, and then creates a Sessionfactory object. Although the configuration interface plays only a small role throughout the Hibernate project, it is the object that you encounter when you start hibernate.

Hibernate database Persistence layer Framework

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.