首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.hibernate.MappingException: entity: Invoice列: INVOICE_ID映射中的重复列

org.hibernate.MappingException: entity: Invoice列: INVOICE_ID映射中的重复列
EN

Stack Overflow用户
提问于 2013-04-06 18:35:05
回答 1查看 938关注 0票数 0

Hibernate表示对列INVOICE_ID的映射是重复的。但是我不能理解这个例外。请帮帮我!!我的发票类如下:

代码语言:javascript
复制
    @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作为外键,如下所示:

代码语言:javascript
复制
@OneToMany
    @JoinColumn(name="INVOICE_ID", nullable=false)
    public Set<Invoice> getInvoices() {
        return invoices;
    }
EN

回答 1

Stack Overflow用户

发布于 2013-04-06 19:05:19

这个映射对我来说毫无意义。

表INVOICE的INVOICE_ID列(它的主键)如何充当USER.ID列的外键?

INVOICE中应该有一个USER_ID列,并且此列应该用作您的OneToMany关联的JoinColumn:

代码语言:javascript
复制
@OneToMany
@JoinColumn(name="USER_ID", nullable=false)
public Set<Invoice> getInvoices() {
    return invoices;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15849815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档