0

我有两个班级:FurniturePainting。那些正在扩展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;
    }

家具有以下代码:

@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-object,通过实体管理器持久化它。我收到以下错误:

对象:auction.domain.Furniture@5d3468fd 不是已知的实体类型。

好像我忘记了什么或做错了什么,可能是在Painting课堂上。会是什么呢?

4

1 回答 1

0

我忘了更新我的持久性单元。添加FurniturePainting类后,信息进入数据库。上面的代码是正确的。

于 2013-01-08T18:49:29.963 回答