I’m using these entities with JPA+Hibernate:
@Entity
public class Game {
@Id
@GeneratedValue
private long id;
@ManyToMany
@JoinTable(name="Game_admins")
private Set<User> admins = new HashSet<User>();
...
@Entity
public class User {
@Id
@GeneratedValue
private long id;
...
Thus far everything works well. Hibernate generates a join table called Game_admins with two colums, Game_id and admins_id.
However, if I add this to User:
@ManyToMany(mappedBy="admins")
private Set<Game> adminForGames = new HashSet<Game>();
The join table suddenly gets three columns, one of which is adminForGames_id. I don’t need or want that, and I don’t think it should be generated since I specify mappedBy. What am I doing wrong?
I believe you need to set the inverseJoin attriubtes