Table per Class strategy:the <union-class> element in Hibernate
Single Table/Class hierarchy strategy:the <subclass> element in Hibernate
Joined subclass Strategy:the <joined-subclass> element in Hibernate
EJB supports three kinds of mapping relationships
1, one table per class (Hibertnate <union-class>)
2, one table for each class level (in Hibernate <subclass>)
3, connected subclasses (corresponding to Join-subclass)
Annotations are not currently supported on interfaces
(1) A table for each class:
Set on the parent class Class-level: @Inheritance (Strategy=inheritancetype.table_per_class)
For example:
Java code
Class A code:
@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 code:
@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 code:
@Entity
public class C extends a{
Private String CNAME;
Public String Getcname () {
return CNAME;
}
public void Setcname (String cname) {
This.cname = CNAME;
}
}