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)