2013-04-06 3 views
0

Hibernate에서 INVOICE_ID 열에 대한 매핑이 반복된다고 말하고 있습니다. 그러나 나는이 예외를 이해할 수 없다. 도와주세요 !! 내 송장 클래스는 아래와 같습니다 : 아래로 내가 USERS 테이블에 외래 키로 INVOICE_ID을 사용했다org.hibernate.MappingException : 엔터티에 대한 매핑의 반복 열 : Invoice 열 : 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; 
     } 

    } 

:

@OneToMany 
    @JoinColumn(name="INVOICE_ID", nullable=false) 
    public Set<Invoice> getInvoices() { 
     return invoices; 
    } 

답변

1

이 매핑은 나에게 아무 의미가 없습니다.

테이블 INVOICE (기본 키)의 INVOICE_ID 열이 USER.ID 열에 대한 외래 키 역할을 할 수 있습니까?

는 INVOICE의 USER_ID 컬럼이 있어야하고,이 열은 OneToMany 협회에 대한 JoinColumn 역할을한다 :

@OneToMany 
@JoinColumn(name="USER_ID", nullable=false) 
public Set<Invoice> getInvoices() { 
    return invoices; 
} 
관련 문제