Detailed explanation of the working principle and architecture of hibernate

Source: Internet
Author: User

Initialization of the 1.Hibernate.

Read Hibernate configuration information-〉 Create session Factory

1 Create an instance of the Configeration class.

How it is constructed: reads the configuration information (Hibernate config.xml) into memory.

A Configeration instance represents a collection of all Java classes to the SQL database map hibernate.

2) Create Sessionfactory instance

Copies all configuration information from the Configeration object to the Sessionfactory cache.

The Sessionfactory instance represents a database storage source, and is no longer associated with the Configeration object after it is created.

Cache: A property of a Java object (usually a property of some collection type) that occupies memory space.

Sessionfactory Cache: Hibernate configuration information. or map metadata.

Cache-Large: Heavyweight object small: Lightweight object

3 The method of calling Sessionfactory to create a session

1 "The user provides the JDBC connection on its own.

Connection con=datasource.getconnection ();

Session s=sessionfactory.opensession (Con);

2 "Let Sessionfactory provide connection

Session s=sessionfactory.opensession ();

4 to manipulate database access through a variety of methods provided by the session interface.

Hibernate Caching System

First-level caching:

The session has a built-in cache that holds objects that are loaded by the current unit of work.

Each session has its own separate cache and can only be accessed by the current unit of work.

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.