JPA @ElementCollection不会创建列

时间:2013-11-15 14:35:57

标签: java jpa orm

在我的应用程序中,我有@Entity 嵌入一个Request类,其中包含Issue属性和Attachment个列表。
Attachment也是Issue Issue Code属性为numberyear,因此我有:

@Embeddable
public class Code{
     private Long number;
     private Integer year;
}

@Embeddable
public class Issue{
    private Code code;
}

@Embeddable
public class Attachment extends Issue{
     @ManyToOne
     private Category category;
}

@Embeddable
public class Request{
    @AttributeOverrides(value={
        @AttributeOverride(name="code.year", column=@Column(name="issue_year")),
        @AttributeOverride(name="code.number", column=@Column(name="issue_number")),
    })
    private Issue issue;

    @AttributeOverrides(value={
        @AttributeOverride(name="code.year", column=@Column(name="attachment_year")),
        @AttributeOverride(name="code.number", column=@Column(name="attachment_number")),
    })
    @ElementCollection
    @CollectionTable(name="attachments")
    private List<Attachment> attachments;
}

现在的问题是,在生成的表中,我有attachments表但没有attachment_yearattachment_number列!

我做错了什么?

0 个答案:

没有答案