我有两个课程:Furniture
和Painting
。这些正在扩展Item
。
项目具有以下代码:
@Entity
public class Item implements Comparable, Serializable {
@Id @GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
@ManyToOne
private User seller;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "description",
column = @Column(name = "c_description"))})
private Category category;
private String description;
public Item() {
}
public Item(User seller, Category category, String description) {
this.seller = seller;
this.category = category;
this.description = description;
this.seller.addItem(this);
}
绘画具有以下代码:
@Entity
public class Painting extends Item {
private String title;
private String painter;
public Painting() {
}
public Painting(String title, String painter, User seller, Category category, String description) {
super(seller, category, description);
this.title = title;
this.painter = painter;
}
Furniture具有以下代码:
@Entity
public class Furniture extends Item {
private String material;
public Furniture() {
}
public Furniture(String material, User seller, Category category, String description) {
super(seller, category, description);
this.material = material;
}
之前,我尝试了一些持久化Item
对象的代码。这工作得很好。
现在我试图坚持一个Painting
- 对象,通过实体管理器持久化它。
我收到以下错误:
对象:auction.domain.Furniture@5d3468fd不是已知的实体类型。
似乎我忘记了某些事情或做错了什么,可能是在Painting
- 班级。它可能是什么?
答案 0 :(得分:0)
我忘了更新我的持久单元。添加Furniture
和Painting
类后,信息将进入数据库。上面的代码是正确的。