2013-01-08 3 views
0

두 클래스가 있습니다 : FurniturePainting입니다. 그것들은 Item입니다. 나는 지속 몇 가지 코드를 시도하기 전에확장 개체가 데이터베이스에 지속되지 않음

@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; 
    } 

:

@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 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); 
    } 

회화는 다음과 같은 코드가 있습니다 :

항목은 다음과 같은 코드가 있습니다 Item 개체. 그게 잘 됐어. 이제 Painting -object를 유지하고 Entity Manager를 통해 영속화하려고합니다.

Object: [email protected] is not a known entity type.

내가 뭔가를 잊어 버렸거나 아마도 Painting -class에서 뭔가 잘못을 한 것처럼 보인다 나는 다음과 같은 오류가 발생합니다. 뭐가 될수 있었는지?

+0

어떻게 엔티티 클래스로 테이블을 매핑 했습니까? 이클립스 링크 @Table annotation과 함께 사용한다. – vels4j

+0

나는 그것이 무엇을 의미하는지 이해하지 못한다. 이것은 내가이 질문에 대해 상대적인 모든 코드입니다. 그래서 아마도 나는 뭔가를 놓치고 있습니까? – Joetjah

답변

0

퍼시스턴스 유닛을 업데이트하는 것을 잊었습니다. FurniturePainting 클래스를 추가하면 정보가 데이터베이스에 저장됩니다. 위의 코드는 정확합니다.

관련 문제