2013-08-22 147 views
2

的類型我有一個簡單的JPA映射,但我不斷得到一個Could not determine type for異常。安裝者和獲取者被省略。JPA繼承無法確定

@Entity 
@Inheritance(strategy = InheritanceType.JOINED) 
public class SupervisionCommand { 

    @Id 
    @GeneratedValue 
    protected Long id; 

} 

@Entity 
public class MySupervisionCommand extends SupervisionCommand { 

} 

@Entity 
public class Job { 

    @Id 
    @GeneratedValue 
    private Long id; 

    private SupervisionCommand command; 

} 

完整的異常消息:Could not determine type for: com.family.model.SupervisionCommand, at table: job, for columns: [org.hibernate.mapping.Column(command)]

回答

7

你需要在命令OneToOne或多對一的註釋(取決於實際的基數):

@ManyToOne 
private SupervisionCommand command; 

的默認映射領域是@Column。而Hibernate不知道使用哪種類型的列(varchar?number?)來存儲SuperVisionCommand實例。如果它實現了Serializable,Hibernate會將其序列化並將其存儲在BLOB列中,但這不是您想要的。