A detailed introduction to the ORM framework.

Source: Internet
Author: User

A detailed introduction to the ORM framework.

Orm:

Object relationship ing changes the original operations on database tables and fields to operations on classes and objects. It is a ing between objects and relations, mainly to map program objects to relational database data. Generally, you do not need to perform database operations, such as writing SQL statements and creating tables.

Hibernate is An orm framework. Because hibernate is heavily encapsulated with jdbc, it does not need to write SQL statements. When using hibernate to operate databases, it does not even need to create tables. It is fully automated, so it belongs to the orm framework.

Add the following code to hibernate. cfg. xml:

Xml Code <property name = "hbm2ddl. auto"> update </property>

Update: indicates that the table structure is automatically updated based on the model object. When hibernate is started, the database is automatically checked,

If a table is missing, the table is automatically created. If a column is missing in the table, the column is automatically added.

There are other parameters:

Create: When hibernate is started, the original table is automatically deleted and all new tables are created. Therefore, the previous data is lost after each start.

Create-drop: When hibernate is started, tables are automatically created. When the program is closed, all corresponding tables are automatically deleted.

So at the end of the program, the table and data will no longer exist.

PS: the database needs to be created in advance, because hibernate only creates tables and does not create databases.

Mybatis Is An orm framework, but it is not. Specifically, mybatis is a semi-orm framework. Because orm encapsulates jdbc in a moderate manner, it encapsulates database connection operations, transactions, and returned results to be processed as List objects, however, he needs to create his own tables and write his own SQL statements. Therefore, it is a semi-automated framework and a semi-orm framework.

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.