Hibernate Learning 1-Overview

Source: Internet
Author: User
1. Introduction

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.

1.1. Overview

1.2. Core interfaces and Classes

Hibernate has five core interfaces: Session, sessionfactory, transaction, query, and configuration. These five core interfaces are used in any development. Through these interfaces, you can not only access persistent objects, but also control transactions. These five core interfaces are described below.

L configuration interface:

The configuration interface is responsible for configuring and starting hibernate to create the sessionfactory object. During hibernate startup, the configuration class instance first locates the ing document location, reads the configuration, and then creates the sessionfactory object.

Two Methods for hibernate Configuration:

Ø property file (hibernate. properties)

Call code: configuration CFG = new configuration ();

XML file (hibernate. cfg. XML)

Call code: configuration CFG = new configuration (). Configure ();

L sessionfactory interface:

The sessionfactory interface initializes hibernate. It acts as a proxy for the data storage source and is responsible for creating session objects. The factory model is used here. Note that sessionfactory is not lightweight, because generally, only one sessionfactory is required for a project. When you need to operate multiple databases, you can specify a sessionfactory for each database. Sessionfactory = cfg. buildsessionfactory ();

L session interface:

The session interface is responsible for executing the CRUD operation on the Persistent Object (the crud task is to complete the communication with the database, including many common SQL statements .). However, it should be noted that the session object is non-thread-safe. At the same time, the hibernate session is different from the httpsession In the JSP application. Here, when we use the term session, it actually refers to the session in hibernate, and later we will call the httsemi sion object a user session.

L transaction interface:

The transaction interface is responsible for transaction-related operations. It is optional. developers can also design and write their own underlying transaction processing code.

L query and criteria interfaces:

Query and criteria interfaces are used to perform various database queries. It can be expressed in hql or SQL statements.

2. Brief introduction to the source code package

Net. SF. hibernate. *: the classes of this package are basically interface classes and exception classes.

Net. SF. hibernate. cache. *: Implementation class of JCs

Net. SF. hibernate. cfg. *: Configuration File Read class

Net. SF. hibernate. collection. *: hibernate collection interface implementation class, such as list, set, and bag. hibernate needs to compile the collection interface implementation class to support lazy loading.

Net. SF. hibernate. Connection. *: provider of several database connection pools

Ø net. SF. hibernate. dialect. *: multiple database features are supported. Each dialect implementation class represents a database that describes the supported data types and other features, such as autoincrement and sequence, paging SQL?

Net. SF. hibernate. eg. *: examples used in the hibernate document

Net. SF. hibernate. Engine. *: the class functions of this package are scattered.

Net. SF. hibernate. expression. *: Expressions supported by hql

Net. SF. hibernate. HQ. *: hql implementation

Net. SF. hibernate. Id. *: Id Generator

Net. SF. hibernate. impl. *: core package, implementation class of some important interfaces, if session, sessionfactory, query, etc.

Net. SF. hibernate. JCA. *: JCA support. The session is packaged as an interface implementation class that supports JCA.

Ø net. SF. hibernate. JMX. *: I don't understand JMX. I only know that JMX is used to compile the Management Program of the app server. It is probably the implementation of some JMX interfaces, so that the app server can manage hibernate through the JMX interface.

Net. SF. hibernate. loader. *: it is also a core package, mainly used to generate SQL statements.

Net. SF. hibernate. lob. *: blob and clob support

Net. SF. hibernate. Mapping. *: attribute Implementation of hBM files

Net. SF. hibernate. Metadata. *: Meta implementation of Po

Net. SF. hibernate. ODMG. *: ODMG Is An ORM standard. This package is an implementation class of the ODMG standard.

Net. SF. hibernate. persister. *: core package to realize the ing between persistent objects and tables.

Net. SF. hibernate. Proxy. *: Support for proxy and lazy loading

Net. SF. hibernate. PS. *: this package is preparedstatment cache.

Net. SF. hibernate. SQL. *: generate a jdbc SQL statement package

Net. SF. hibernate. Test. *: Test class. You can use JUnit to test hibernate.

Net. SF. hibernate. tool. hbm2ddl. *: Generate DDL using HBM configuration file

Net. SF. hibernate. transaction. *: hibernate transaction implementation class

Net. SF. hibernate. type. *: the data type of the Persistent Object attribute defined in hibernate.

Net. SF. hibernate. util. *: Some tool classes with scattered Functions

Net. SF. hibernate. xml. *: XML Data Binding

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.