I have two tables with foreign key relations. I\'ve tried searching on how to do it and it always leads to OneToMany & ManyToOne mapping. I have these two tables.
<
You have to annotate the Java fields not the getter like:
@OneToMany(targetEntity=User.class, mappedBy="userRole",cascade=CascadeType.ALL, fetch = FetchType.LAZY)
private List user;
and for User.class
@ManyToOne
@JoinColumn(name="role_id")
private UserRole userRole;
In addition, do you have defined the role_id column in the user table? I can't see this in the screenshot