Hibernate's Preliminary

Source: Internet
Author: User

1. Introduction

In the field of Java development, design and implementation based on database applications have always been relational, and the advent ofHibernate object/Relational Mapping ORM Framework provides easy-to-use data persistence for Java object-oriented development Solutions.

  ORM Introduction:

 (a). ORM (Object Relation Mapping) Chinese translation into Object Relational mapping

(b). ORM is a technique that appears to solve the mismatch between "object-oriented" and "relational database" .

(c). ORM automatically persists objects in Java programs into relational databases by using metadata that describes the mappings between objects and databases

(d). The mapping relationship in ORM is: Object-Oriented (class/object/attribute)-oriented relationships (Table/table Rows (records)/Table columns (fields))

 (e). The idea of ORM implementation: Mapping the records of tables in a relational database (the rows of a table) into objects, presented as objects, programmers can translate the operations of the database into objects

(f). Popular ORM Framework:Hibernate, Ibatis, TopLink, Apache OJB

Hibernate Maps the relationship between objects in Java and objects in relational databases into tables and tables , and acts as a bridge between Java applications and relational databases. It encapsulates JDBC access to the database and provides an object-oriented database access API to the upper layer.

  Here is the difference between hibernate and JDBC borrowed from a picture on the Web:

  

2.Hibernate Operating Process

(a). Application calls to the configuration class

(b). The configuration class reads the hibernate configuration file and the mapping file and uses this information to generate a sessionfactory class .

(c). Generating a Session object from the sessionfactory class

(d). Generate a transaction object with the Session object

(e). Available through the Session object's get (), load (), save (), update (), delete (), and Saveorupdate () methods on the Pojo class (plain old Java object) loading, saving, updating, deleting, etc.

 Pojo Introduction:

(A ') POJO (plain old Java object): Simple Java object, plain Java class .

(b ') POJO practical meaning is common JavaBeans(The simplest Java class, that is, a class has only attributes, then a large heap of set,get and ToString methods)

(c ') POJO is characterized by support for the business logic of the class, does not inherit the non-implementation does not comment

  JavaBean Introduction:

(A ') JavaBean is Pojode's Serializable (serialization), which is typically created by a container (such as Tomcat), so it should have a parameterless constructor. It is also a component technology that cannot be accessed across processes.

(b ') JavaBean is a reusable component written in the Java language. To write JavaBean, the class must be concrete and public, and have a parameterless constructor.

(c ') JavaBean gets the internal domain exposed member properties, set and get methods by providing a public method that conforms to the consistent design pattern.

(d ') it is well known that attribute names conform to this pattern, and other Java classes can discover and manipulate the properties of these javabean through introspection mechanisms.

(f). In the case of a query, a query object can be generated from the session object and then executed with the Queries object, and if there is no exception, the transaction object commits the operations to the database, and if an exception occurs, it is rolled back.

3.Hibernate Project Hierarchy:

Hibernate can be divided into the following layers from the more popular MVC pattern

data layer : Refers to the design of the database

DAO Layer: A DAO (data Access object) that accesses objects . The DAO layer is presented to realize the separation of the operation of the data and the operation of the business, and the DAO layer provides the interface of accessing data directly to the upper business logic layer. (DAO layer is more important)

business Logic Layer : This encapsulates the business logic layer into a service that is directly called by the control layer.

control layer and view layer : Visible layer, adopt jsp,html,css,ajax and so on.

Hibernate's Preliminary

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.