Hibernate 是说重复列 INVOICE_ID 的映射。但我无法理解这个例外。请帮忙 !!我的发票类如下:
@Entity
@Table(name="INVOICES")
public class Invoice {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="INVOICE_ID", nullable=false,insertable=false,updatable=false)
private Integer invoice_id;
@Column(name="Date_Created", nullable=false)
private Timestamp dateCreated;
@Column(name="DESCRIPTION")
private String description;
@Column(name="Total_Amount")
private Double totalAmount;
@Column(name="Tax_Amount")
private Double taxAmount;
@Column(name="Due_Date")
private Timestamp dueDate;
@Column(name="deleted")
private boolean deleted;
@OneToOne
@JoinColumn(name="Invoice_Item_Detail_id", nullable=false)
private InvoiceItemsDetails invoiceItemsDetails;
@OneToOne
@JoinColumn(name="ID", nullable=false)
private Client client;
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
public Date getDueDate() {
return dueDate;
}
public void setDueDate(Timestamp dueDate) {
this.dueDate = dueDate;
}
/* public Integer getInvoice_id() {
return invoice_id;
}
public void setInvoice_id(Integer invoice_id) {
this.invoice_id = invoice_id;
}
*/
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Timestamp dateCreated) {
this.dateCreated = dateCreated;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(Double totalAmount) {
this.totalAmount = totalAmount;
}
public Double getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(Double taxAmount) {
this.taxAmount = taxAmount;
}
public boolean isDeleted() {
return deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public InvoiceItemsDetails getInvoiceItemsDetails() {
return invoiceItemsDetails;
}
public void setInvoiceItemsDetails(InvoiceItemsDetails invoiceItemsDetails) {
this.invoiceItemsDetails = invoiceItemsDetails;
}
}
我在 USERS 表中使用 INVOICE_ID 作为外键,如下所示:
@OneToMany
@JoinColumn(name="INVOICE_ID", nullable=false)
public Set<Invoice> getInvoices() {
return invoices;
}