“基本”属性类型不应为持久性实体
2022-09-03 14:21:07
我在另一个实体类中引用了一个实体,并收到此错误。下面是示例代码。我在持久性中也有这些类.xml。
导致此问题的原因是什么?我正在使用Spring数据JPA和Hibernate。
import javax.persistence.*;
@Entity
@Table(name = "users", schema = "university")
public class UsersEntity {
private long id;
@JoinColumn(name = "address_id", nullable = false)
private Address address;
@Id
@Column(name = "id")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
import javax.persistence.*;
@Entity
@Table(name = "address", schema = "university")
public class AddressEntity {
private long id;
private String street;
@Id
@Column(name = "id")
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "street")
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}