2013-01-08 18 views
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: [email protected] is not a known entity type.

好像我忘了什么事或做错了什么事,可能是在Painting -class。会是什么呢?

+0

你是如何将你的表映射到实体类的? eclipse链接我使用@Table注释 – vels4j

+0

我不太明白你的意思。这是我有这个问题的所有代码,所以也许我错过了什么? – Joetjah

回答

0

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