0

我有这样的ManyToMany映射:

@XmlTransient
    @ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name = "users_clients",
            joinColumns = {@JoinColumn(name = "user_id")},
            inverseJoinColumns = @JoinColumn(name = "client_id"))
    public List<Client> getClients() {
        return clients;
    }

另一边:

@ManyToMany(mappedBy = "clients")
    private List<User> users = new ArrayList<User>();

所以你可以看到我有JoinColumn name = user_idclient_id但是休眠将这些列映射为名称 userS_id 和 clientS_id 作为它们的表名。为什么会这样?有什么建议么?

4

1 回答 1

0

@JoinColumn尝试在注释中指定列名。此外,您在 inverseJoinColumns 周围缺少大括号

    @JoinTable(name = "users_clients",
      joinColumns = {
        @JoinColumn(name = "user_id", referencedColumnName="user_id")},
          inverseJoinColumns = {
        @JoinColumn(name = "client_id", referencedColumnName="client_id")})
于 2012-11-22T11:35:49.203 回答