oneToMany JPA spring

oneToMany JPA spring

我正在尝试 link 两个错误,但我已经分手了

这是一个错误: mappedBy 引用未知目标实体 属性: com.proxy.ProxyBase.proxy_server in com.accounts.AllAccountsBase.proxies

第一个模型

@Data
@Entity
@Table(name = "all_accounts")
public class AllAccountsBase {

    @Id
    @Column(name = "login", nullable = false, unique = true)
    private String login;

    @Column(name = "password")
    private String password;

    @Column(name = "old_password")
    private String oldPassword;

    @Column(name = "phone")
    private String phone;

    @Column(name = "recovery_email")
    private String recoveryEmail;

    @Column(name = "recovery_pass")
    private String recoveryPass;

    @Column(name = "virt_machine")
    private String machineName;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "personal_data_id")
    private PersonalData personalData;

    @Column(name = "account_status")
    private Integer accountStatus;

    @Column(name = "time_update")
    private Timestamp timeUpdate;

    @Column(name = "server_group")
    private String serverGroup;

    @Column(name = "server", nullable = false, unique = true)
    private String server;

    @OneToMany(
            mappedBy = "proxy",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY
    )
    private Collection<ProxyBase> proxies = new ArrayList<>();

}

在模型中,我添加了一对多的关系,反之亦然

第二个模型

@Data
@Entity
@Table(name = "proxy")
public class ProxyBase implements Serializable {

    @Id
    @Column(name = "server", nullable = false, unique = true)
    private String server;

    @Column(name = "proxy_data")
    private String proxyData;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "all_accounts_server")
    private AllAccountsBase allAccountsBase;

}

请帮忙

我做的不一样:

@Data
@Entity
@Table(name = "proxy")
public class ProxyBase implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

    @Column(name = "server", nullable = false)
    private String server;

    @Column(name = "proxy_data")
    private String proxyData;
}

@Data
@Entity
@Table(name = "all_accounts")
public class AllAccountsBase implements Serializable {

    @Id
    @Column(name = "login", nullable = false, unique = true)
    private String login;

    @Column(name = "password")
    private String password;

    @Column(name = "old_password")
    private String oldPassword;

    @Column(name = "phone")
    private String phone;

    @Column(name = "recovery_email")
    private String recoveryEmail;

    @Column(name = "recovery_pass")
    private String recoveryPass;

    @Column(name = "virt_machine")
    private String machineName;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "personal_data_id")
    private PersonalData personalData;

    @Column(name = "account_status")
    private Integer accountStatus;

    @Column(name = "time_update")
    private Timestamp timeUpdate;

    @Column(name = "server_group", nullable = false)
    private String serverGroup;

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(
            name = "proxy_key",
            joinColumns = @JoinColumn(name = "server_group", referencedColumnName = "server_group"),
            inverseJoinColumns = @JoinColumn(name = "proxy_server_group", referencedColumnName = "server"))
    private Collection<ProxyBase> proxies = new ArrayList<>();

}