Hibernate mapping: OneToMany and OneToOne on child object property

后端 未结 3 1045
故里飘歌
故里飘歌 2020-12-19 09:34

Here is parent class Enterprise. It has employers and one of them is president of enterprise.

@Entity
class Enterprise
{
   // fields

   @OneToMany
   publi         


        
3条回答
  •  旧巷少年郎
    2020-12-19 10:01

    Use @ManyToOne annotation. It is the opposite side of a one-to-many relation. It says an employee can have one enterprise, but an enterprise can have many employees.

提交回复
热议问题