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
1
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