0
votes

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;
  1. 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.

  1. What will be the difference if i don't define ManyToOne mapping ?
1

1 Answers

0
votes

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