Получаю данную ошибку при создании таблици! Кто сможет объяснить в чём дело ?
A Foreign key refering com.demo.User from com.demo.Address has the wrong number of column
@Entity
@Table(name = "users")
public class User {
public User(){}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", first_name='" + first_name + '\'' +
", salary=" + salary +
", last_name=" + last_name +
'}';
}
public Collection<Address> getAddresses() {
return addresses;
}
public void setAddresses(Collection<Address> addresses) {
this.addresses = addresses;
}
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "addresses" , joinColumns = {@JoinColumn(name = "user's_city"),@JoinColumn(name = "user's_country")})
private Collection<Address> addresses = new ArrayList<>();
@Id
@Column(name = "user's_id")
private int id;
@Column(name = "first_name")
private String first_name;
@Column(name = "user_salary")
private int salary;
@Column(name = "last_name")
private String last_name;
}
@Entity
@Table(name = "addresses")
public class Address {
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Override
public String toString() {
return "Address{" +
"street='" + street + '\'' +
", country='" + country + '\'' +
", city='" + city + '\'' +
'}';
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "users", inverseJoinColumns = @JoinColumn(name = "user's_id"))
private User user;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "user's_street")
private String street;
@Column(name = "user's_country")
private String country;
@Column(name = "user's_city")
private String city;
public Address(){}
}