来自Embeddable Object的字段列表中的未知列

时间:2015-12-05 19:36:17

标签: java jpa eclipselink

我正在尝试将Category嵌入Item。但是,当我这样做时,会给我一个错误,即列category未知。

@Embeddable
public class Category {

    private String description;

    private Category() {
        description = "undefined";
    }

    public Category(String description) {
        this.description = description;
    }

    public String getDiscription() {
        return description;
    }
}

项目

@Entity
@NamedQueries({
    @NamedQuery(name = "Item.getAll", query = "select a from Item as a"),
    @NamedQuery(name = "Item.count", query = "select count(a) from Item as a"),
    @NamedQuery(name = "Item.findByDescription", query = "select a from Item as a where a.description = :descriptions")
})
public class Item implements Comparable, Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    @JoinColumn(name = "email")
    private User seller;

    @Embedded
    @AttributeOverrides({
        @AttributeOverride(name = "description",
                column = @Column(name = "category"))})
    private Category category;

    @Column(name = "description")
    private String description;

    @OneToOne(optional = true)
    private Bid highest;

    public Item(User seller, Category category, String description) {
        this.seller = seller;
        this.category = category;
        this.description = description;
    }

    public Item() {

    }

1 个答案:

答案 0 :(得分:0)

我所做的更改无论如何都不会影响数据库。所以新专栏从未创建过。