hibernate annoation (七 继承映射)
2009-09-18 00:00:00 来源:WEB开发网Table per Class Strategy: the <union-class> element in Hibernate
Single Table per Class Hierarchy Strategy: the <subclass> element in Hibernate
Joined Subclass Strategy: the <joined-subclass> element in Hibernate
ejb支持三种映射关系
1,每个类一张表 (hibertnate里对应<union-class>)
2,每个类层次一张表 (在 hibernate里对应<subclass>)
3,连接的子类(对应join-subclass)
目前不支持在接口上进行注解
(1)每个类一张表:
在父类class-level上设置:@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
例如:
Java代码
class A代码:
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class A {
private int id;
private String aname;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAname() {
return aname;
}
public void setAname(String aname) {
this.aname = aname;
}
}
class B extends A代码:
@Entity
public class B extends A{
private String bname;
public String getBname() {
return bname;
}
public void setBname(String bname) {
this.bname = bname;
}
}
class C extends A代码:
@Entity
public class C extends A{
private String cname;
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
}
- ››Hibernate高级应用:性能优化策略
- ››hibernate 多对多关系详解(包括中间表,一对多字表...
- ››Hibernate实现mysql数据库limit查询方法
- ››Hibernate 之父:是时候升级到Java EE 6了
- ››Hibernate查询
- ››Hibernate和iBATIS比较(摘自网络)
- ››Hibernate使用Projections进行聚合操作
- ››hibernate中java.util.Date类型映射
- ››hibernate中update与saveOrUpdate的区别
- ››Hibernate各种映射关系总结
- ››Hibernate过滤器使用窍门
- ››Hibernate属性查询简单讲述
更多精彩
赞助商链接