One-to-many association relationship
Correlation characteristics: 1 of the party has n the one side of the collection attribute, N of the party does not have 1 of the side of the reference
For example, if the customer has a one-to-many association with order, the customer has an order collection attribute, and the order does not have a reference to the customer. This allows the customer to retrieve all of their order information, but is not able to get the customer to whom the order belongs.
There are two key points to mapping a one-to-many association relationship:
1, using @onetomany annotations for one-way-to-many mappings;
2, using @joincolumn to map the name of the foreign key column;
Note the point:
1. The default retrieval policy for @OneToMany is a deferred load policy, which can be modified to retrieve the policy immediately by setting its property fetch=fetchtype.eager;
2. A one-way-to-many association set by @OneToMany can delete 1 of the party by default.
Processing: First set all foreign keys of its associated n data table to NULL, and then delete the 1 side.
You can set the @onetomany property Cascade={cascadetype.remove} to cascade Delete (delete the 1 side and delete the same side simultaneously, you can also set the other delete policy )
7, unidirectional one-to-many relationship (1 of the party has N of the party's set properties, N is not a side of the 1 of the reference)