Hibernate classic summary

Source: Internet
Author: User

Hibernate classic summary 1. what is Hibernate? What is a data access framework (persistence layer framework ), in the project, you can use the Hibernate frame to add, delete, modify, and query databases and build a persistent layer for the business layer. (2) The Hibernate framework is mainly used for database operations. Using this framework can simplify data operation code, allowing programmers to focus more on business writing. Hibernate classic summary Hibernate is essentially an encapsulation of JDBC technology. The relationship between Hibernate and JDBC is similar to that between JQuery and JavaScript. (3) The original JDBC Method to access the database has the following shortcomings:. A large number of complex SQL statements are required. A large number of objects and records need to be converted. c. when porting a database, you must modify the SQL statement. (Non-standard SQL statements, such as paging statements and statements using database functions) after the Hibernate framework is used, the above problems can be solved (4). Advantages of The Hibernate framework:. no need to write a large number of complex SQL statements B. the entity objects in the program and the data in the database realize automatic ing and conversion c. facilitate database migration 2. the Hibernate framework is an ORM tool. Developed based on the ORM design idea. ORM: Object -- Relation -- Mapping Object Relational ing Object refers to the Java Object, and the Relation refers to the relational database. (Oracle, DB2, MySql, and SqlServer) the main idea of ORM is to implement automatic ing and conversion between objects in the program and data in the database. By using the ORM tool, records can be automatically encapsulated into Java objects during query. Objects can be automatically written to the data table during update and insert operations. For intermediate SQL + JDBC operation details, there are many frameworks fully encapsulated in the bottom layer of the tool designed based on ORM ideas, such as Hibernate, iBATIS, JPA, etc. * 3. the Hibernate framework mainly consists of the following parts:. java object classes (1-N) correspond to data tables, used to encapsulate a row of records in a data table. B. hibernate. cfg. xml (1) The main configuration file of Hibernate, which mainly defines database connection parameters and framework parameters. <Hibernate-configuration> <session-factory> <! -- Dialect settings. hibernate automatically generates the SQL statement <property name = "dialect"> org. hibernate. dialect. oracleDialect </property> <property name = "connection. url "> jdbc: oracle: thin :@ localhost: 1522: xe </property> <property name =" connection. username "> system </property> <property name =" connection. password "> zhuxun </property> <property name =" connection. driver_class "> oracle. jdbc. driver. oracleDriver </property> <! -- Print the SQL statement from the console --> <property name = "show_ SQL"> true </property> <property name = "format_ SQL"> true </property> <! -- Format the SQL statement --> <! -- Load the ing description file --> <mapping resource = "entity/Cost. hbm. xml "/> </session-factory>

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.