Why not recorded the id with@OneToMany?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
When pitois record Department with full of guns collection employees - get saved on the Employee entity, but without a foreign key on Department.
BUT when you do a crutch, like: employee.setDartpent(Department), add some employees, get a foreign key on department!
What could be my mistake? For any constructive hunch I would be grateful. Maybe she will be my decision to make.

@Entity class Department{ @Id @GeneratedValue private Integer id; @OneToMany(mappedBy = "department", cascade=CascadeType.ALL) private List employees= new ArrayList(); } @Entity class Employee{ @Id @GeneratedValue private Integer id; @ManyToOne @JoinColumn(name = "id_department") private Department department; }
by | 11 views

1 Answer

0 like 0 dislike
Just reported that the back binding in my case and as such there is no error.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 4, 2019 by P_Alexander
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,389 users