How hibernate works

Source: Internet
Author: User

1. How does hibernate connect to the database?

The configuration class uses the XML Parser of dom4j to set the XML parsing environment. Then, these environment attributes are used to produce sessionfactory. Then session is produced.

2. How does hibernate perform database write operations?

After session. Save (), the object is marked as persistent, but hibernate has not actually executed the insert statement. When the session is refreshed and synchronized, Hibernate willExecute all SQL statements in session cache together

3. How does hibernate load objects from the database?

When using session. Load () to load objects, you can set whether to use delayed loading (Cglib/Javassist return proxy class), The proxy class contains the Object ID. When used, Hibernate will first read from the session. If the cached data does not exist or is dirty, and the second-level cache is configured, hibernate will try to retrieve data from second-level cache in China

4. How does hibernate perform database query?

Hibernate provides the SQL, hql, and criteria query methods for session. createquery ("hql"), session. createsqlquery ("SQL"), session. createcriteriaquery ()... hibernate will useThe anltr database parses hql statements into SQL statements that can be identified by JDBC.

Common hibernate tools


Java reflection mechanism: bytecode enhancement proxy/invocationhandler

Cglib: ASM project bytecode Enhancement

Javassist: bytecode enhancement, which provides two levels of APIS (Source codeLevel and bytecode level)

2. xml file and dom4j parser

3. anlr

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: 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.