Persistence API (JPA) series (vi) Mapping types of Entity Relationship mapping (ORM)

Source: Internet
Author: User

ORM Entity Relationship Mapping, the relationship between data tables and tables in a database, is manifested by the relationship between entity bean and entity bean, and the operation of database by manipulating entity Bean is realized.

ORM (Object-relation-map), where Object represents the entity bean,relation represents the data table, and map represents the mapping of the entity bean to the data table.

Because the entity bean in EJB3 uses the JPA framework, the ORM here refers to the JPA mapping. It also acts like an entity relationship mapping in the persistence layer framework of Hibernate, IBATIS, JDO, TopLink, and so on.


Depending on the relationship between the table and the table, the type of the entity bean mapping is as follows.

Single-table mapping: Maps an entity to a separate table in the database.

One-to-one mapping: mapping to a one-to-one mapping in a data table, using @onetoone annotation definitions.

One-to -many relationship mapping: Maps to a one-to-many mapping relationship in a data table, using the @onetomany annotation definition.

Many-to-one relationship mapping: Maps to a many-to-one mapping relationship in a data table, using @manytoone annotation definitions.

Many-to-many relationship mappings: Maps to a many-to-many mapping relationship in a data table, using the @manytomany annotation definition.


ORM Basic Correspondence Rules:
1. The class corresponds with the table
2. The properties of the class correspond to the fields of the table
3. Instances of the class correspond to a specific record in the table


The following will explain in detail the development methods of the 5 mapped entity beans.


Persistence API (JPA) series (vi) Mapping types of Entity Relationship mapping (ORM)

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.