我是 Hibernate 的初学者。
我收到此错误消息,但无法弄清楚出了什么问题:
线程“主”org.hibernate.MappingException 中的异常:实体映射中的重复列:com.hibernate.aris.Subscribers 列:城市(应使用 insert="false" update="false" 进行映射)"
我在某处读到必须将 HBM 文件中的属性设置为“反向”,但我还不知道这意味着什么。
任何意见,将不胜感激?
称为地址的可嵌入类
@Embeddable
public class Address {
@Column (name = "STREET_NAME")
private String street;
@Column (name = "CITY_NAME")
private String city;
@Column (name = "POST_CODE")
private String postcode;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
}
订户类
@Entity
@Table(name = "Subscriberstbl")
public class Subscribers {
private int subID;
private String firstname;
private String lastname;
@Embedded
@AttributeOverrides({
@AttributeOverride(name ="street", column = @Column(name="HOME_STREET_NAME")),
@AttributeOverride(name = "city", column = @Column(name="HOME_CITY_NAME")),
@AttributeOverride(name = "postcode", column = @Column(name="HOME_POST_CODE"))})
private Address homeaddress;
@Embedded
private Address officeaddress;
//Getters and Setters
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
@Id
@GeneratedValue
public int getSubID() {
return subID;
}
public void setSubID(int subID) {
this.subID = subID;
}
public Address getOfficeAddress() {
return officeaddress;
}
public void setOfficeAddress(Address address) {
this.officeaddress = address;
}
public Address getHomeaddress() {
return homeaddress;
}
public void setHomeaddress(Address homeaddress) {
this.homeaddress = homeaddress;
}
}