[英]Unkown column in field list from Embeddable Object
我試圖將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() {
}
我所做的更改無論如何都不會影響數據庫。 因此,從未創建新列。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.