<b>hibernate annoation (七 承当映射)</b>[Java编程]
本文“<b>hibernate annoation (七 承当映射)</b>[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
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;
}
}
以上是“<b>hibernate annoation (七 承当映射)</b>[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |