我正在尝试将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() {
}
答案 0 :(得分:0)
我所做的更改无论如何都不会影响数据库。所以新专栏从未创建过。