Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
3.2.5.2. Many-to-one
Many-to-one associations are declared at the property level with the annotation
@ManyToOne:
The
@JoinColumn attribute is optional, the default value(s) is like in one to one, the concatenation of the name of the relationship in the owner side, _ (underscore), and the name of the primary key column in the owned side. In this example company_id because the property name is company and the column id of Company is id.
@ManyToOne has a parameter named targetEntity which describes the target entity name. You usually don't need this parameter since the default value (the type of the property that stores the association) is good in almost all cases. However this is useful when you want to use interfaces as the return type instead of the regular entity.
You can also map a many to one association through an association table. This association table described by the
@JoinTable annotation will contains a foreign key referencing back the entity table (through @JoinTable.joinColumns) and a foreign key referencing the target entity table (through @JoinTable.inverseJoinColumns).