Reputation: 125
I am trying to learn Hibernate and just got a bit confused.
I have 2 classes Company and Employee. Company has a set of Employee.
So inside Company i have defined something like
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "COMPANY_ID")
private Set<Employee> employees;
Now do i need to define something like
@ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "COMPANY_ID") private Company company;
inside Employee class as well and also how will it make the difference.
Upvotes: 0
Views: 118
Reputation: 21186
See https://howtoprogramwithjava.com/hibernate-manytoone-unidirectional-tutorial/
It all depends on whether you want a uni-directional one to many or a bi-directional one to many
Upvotes: 0