Java Essentials-Classic Hibernate

Source: Internet
Author: User
Tags odbc connection sessions

in programming development, we have very many frameworks, they are very convenient and very useful, today we come to know a Java the classic frame Hibernate , Hibernate The English name is "hibernation". This is a very interesting technology, the same name is also very clever!

Let's look at the cover of this technical book abroad:



Brief Introduction:

It is known that hibernating animals are delicate, on the brink of freezing, and hibernate is a great role in the realization of data persistence. What is the connection between the two?
Introduction to Data persistence:
Data persistence is the problem of the interaction between the program and the database, so that the program does not directly visit the database, but instead visits the session directly and then "deals" with the database by the session.

Just make sure that every time the program visits the data in the session, it is consistent with the data in the database and there is no error.
The effect of hibernation will be reflected by this session, our program does not directly face the database, delay (hibernation) to session sessions, we can understand session sessions as a cache!


Are you curious? How is this implementation finished?


Let's take a macro look at his magical veil:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvehzzahu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">


And let's look at the pros and cons of using ORM.
Strengths:
1, increase productivity--easy to develop
2, more object--eliminate the relationship domain-impedance mismatch
3, portability--please
4, no intrusion-test simple, support transparent persistence

Disadvantages:
1, database attribute statement--hard tuning
2, there is a problem with the large volume data update
3, there are a lot of statistical queries in the system--hybrid application
At this point, Hibernate is the most helpful to us to use the object-oriented thinking operation relational database!




thinking:Is this a new technology?


This is not a new technology. It is only one person who has done a better job of achieving this technology, which is suitable for most developers. Under the force of time. gradually promote. Hibernate seems to be an independent technology, in fact we have been exposed to this kind of thinking at the stage of VB. When we write a computer room cashier system in VB, a special module encapsulates a series of operations on the database. Contains the Get ODBC connection. Release the connection, and so on, we have made a simple encapsulation of the operation of the database.


In the C # phase, during our personal refactoring and co-development, we did not only do VB to the database connection encapsulation, we also do a series of table operation encapsulation. Let's look at this class diagram:


Comparison:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvehzzahu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">


and in Hibernate the. Let's look at his structure:



We found that while learning hibernate. This technology, we want to object to the database, without regard to the detailed structure of a very good implementation, we used to be able to say that it is a prototype of hibernate. In Hibernate, in addition to these, another good technique embodies the other meaning of his hibernation:


Delay loading
Such an initialization policy reads a relational object only when an object calls its one-to-many or many-to-many relationship. This process is transparent to the developer and requires only very few database operation requests, resulting in a significantly higher performance gain.
Self-Understanding:
He's such a technology. is to enclose the database in a well-wrapped relationship in the use of object invocation, delay loading, only I call this relationship, I will be loaded into the relationship of those objects, so that if we just use an object, we will not call the relationship map to his object!


Mapping in Life:


Are these technologies used in life? This must be an application. Maybe you can't imagine, we use every day!


One of the simplest examples, the meeting, we in life, every community will have a neighborhood committee, each city will have a district-level management institutions, the national meeting, there will be deputies at all levels, and these mechanisms are our delay loading a map, such as a county under the B,c,d three urban areas. City to decorate the task, a county representative to the meeting, with B.C.D three urban representatives. The city has a task to say to a, unless detailed to a certain town. Otherwise, the BCD does not appear. And once there are detailed tasks, detailed to a certain area, just to temporarily call the conference room is OK!




Summary: Hibernate, which is first a word, has its actual meaning in life. Then is the name of a technology or code, and the two must have inextricably linked, and his origin must have a clever story, we do not know hibernate is supposed to think he is a new technology. We know hibernate, after learning that he doesn't know the new technology, we use hibernate because he better to conquer our problems!
In short, the rise of this technology. Not because it's too new. But we are too familiar. Too eager!


Java Essentials-Classic Hibernate

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.