Aby zmusić Hibernate do utworzenia klucza podstawowego z obiema kolumnami, musisz zmienić Collection
przez Set
public class Role {
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(
name = "roles_privileges",
joinColumns = @JoinColumn(
name = "role_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(
name = "privilege_id", referencedColumnName = "id"))
private Set<Privilege> privileges;
}
Oraz:
public class Privilege {
@ManyToMany(mappedBy = "privileges")
private Set<Role> roles;
}