Java programmers go from stupid birds to cainiao (50) to discuss hibernate (1) Basic concepts and architecture of Hibernate

Source: Internet
Author: User

Database operations are an indispensable part of today's traditional application software. Almost all application systems and interactive software used are inseparable from the support of databases. Therefore, database operations are also an essential task, in the world of Java, the traditional database access is JDBC database access. At the beginning of learning, we should be able to meet our needs. However, in actual application, it is complicated to perform operations, the inevitable disadvantages of low development efficiency and code redundancy are also obvious to all. Therefore, an efficient and simple database access framework was born in this tedious work, this is the Hibernate framework that is popular in the world of Java today (this should not be exaggerated). So from today on, I will join you in the hibernate review.

Hibernate Baidu business card:

Hibernate is an open-source object relationship ing framework that encapsulates JDBC objects in a lightweight manner, so that Java programmers can use the object programming thinking to manipulate the database as they wish. Hibernate can be used in any situation where JDBC is used. It can be used in Java client programs or Servlet/JSP web applications. The most revolutionary is that, hibernate can replace CMP in the J2EE architecture of application EJB to fulfill the task of data persistence.

From the Baidu business card above, we can see that:

1) In fact, the underlying layer of Hibernate is still implemented by JDBC, but the tedious operations of JDBC have all made the framework work for us. programmers have been freed from the tedious JDBC operations.

2) Hibernate is an object relationship ing model. That is to say, it mainly operates on the ing between objects and relationships. objects are class objects in Java, but classes are generally some entity classes.

3) Hibernate is not only a web application framework, but also a task of many beginners. It is considered that hibernate is only used in Web development. In fact, this is a very wrong idea.

Persistence:

As we can see above, Hibernate is mainly responsible for data persistence. Many people should think about it. What is persistence? Next let's talk about this persistence: persistence is a mechanism for converting program data between the persistent state and the instantaneous state, the main application of persistence is to store the objects in memory in a relational database. Of course, they can also be stored in Disk Files and XML data files.

(1) transient state (transient)

Data stored in the memory. After the program exits, the data disappears.

(2) persisten)

 

Persistence is persistence, and persistence is time-oriented. the data in the database is persistent data, as long as you do not delete or modify it. for example, in the IE browser, the session object variables remain unchanged in a session, and are persistent in the session container. There are many methods for Object persistence, such as page, session, application,

Hibernate provides efficient o/r relationship ing and query services for applications, and provides a convenient framework for ing Object-Oriented Domain Models to traditional relational databases. It is also a good implementation of Object persistence. A simple example:


 

Object link ing

From the above, we can see that hibernate is an open source object link ing framework. The term object/Relational Database ing (ORM) represents a technology, it is used to map the Objects represented by the object model to the SQL-based relational model database structure. Orm, that is, object-
Relational mapping (Object relationship ing) is used to map relational databases and Business Objects. In this way, when we operate business objects, you don't need to deal with complex SQL statements, as long as you operate on objects as usual. Object relationship ing (ORM) provides a conceptual and easy-to-understand Method for modeling data. The ORM methodology should be based on three core principles:
Simple: data is modeled in the most basic form.
Communication: the database structure is documented in a language that anyone can understand.
Accuracy: Create a correctly standardized structure based on the data model.

 

Next, let's get to know about hibernate,What does hibernate Do?

Hibernate can help us develop relational database-based applications using object-oriented ideas.

1. Save the object data to the database

Second, read the database data into the object.

 

Hibernate architecture:

A brief summary of the hibernate architecture:



From this figure, we can see that hibernate uses database and configuration information to provide persistence services (and persistent objects) for applications ).

Let's take a closer look at the hibernate runtime architecture. Since Hibernate is flexible and supports multiple application solutions, we can only describe the two extreme situations. A lightweight architecture that requires applications to provide their own JDBC connections and manage their own transactions. This solution uses the minimum subset of the hibernate API:



The "Comprehensive Solution" architecture solution abstracts the application layer from the underlying JDBC/jta api, and enables hibernate to process these details.

 

Now, we will introduce the basic concepts and architecture of hibernate. The next blog will help you develop our first hibernate application. Thank you for your support.

 

Related Article

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.