I have got the following tables: Tag, Employee, Location. Employee and Location can have more tags. I think it's best to create new tables for these relations so: employee_tag and location_tag.
How do I do this using JPA? Right now I got this: Employee class:
@OneToMany()
@JoinTable(name="employee_tag", joinColumns={
@JoinColumn(name="ID_employee", referencedColumnName="ID")
}, inverseJoinColumns={
@JoinColumn(name="ID_tag", referencedColumnName="ID")
})
private Collection<Tag> tags;
Tag class:
@ManyToOne()
private Employee employee;
It creates a new table named employee_tag but tag still has a column employee_ID. How do I link the tag to this table?