SpringMVC 中实体类父子类关系设置

 父类:

@Entity 
@Table(name="tbl_AlbumSuper") 
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) 
public class AlbumSuperClass {
    @Id
    @Column(length = 32)
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(strategy = "uuid", name = "system-uuid")
    private String strID;    
    @Column
    private String strName;    
}

 子类:

@Entity
public class VideoAlbum extends AlbumSuperClass{
         //写一些子类特有的属性,如:
  @OneToMany(fetch=FetchType.EAGER)
    @JoinColumn(name="FK_album_ID")
    private Set<Video> videoSet;   
}





Video实体中专辑对象为父类对象
@ManyToOne(cascade=CascadeType.ALL)

@JoinColumn(name = "FK_album_ID")

private AlbumSuperClass beanSuperAlbum; 

posted @ 2011-03-31 15:16  为牛马者,背负前行  阅读(2477)  评论(0编辑  收藏  举报

如果本页面列出的内容侵犯了您的权益,请告知。
知识共享许可协议
996.icu