person表结构:
[img]http://dl.iteye.com/upload/attachment/592705/e2657f7b-f5de-34e0-8988-39303c3c2074.jpg[/img]
teacher表结构:
[img]http://dl.iteye.com/upload/attachment/592707/3369309f-4549-3e66-82d9-f7a264799361.jpg[/img]
student表结构:
[img]http://dl.iteye.com/upload/attachment/592709/e358e162-b3e0-3ef4-af1e-95875f84f542.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/592705/e2657f7b-f5de-34e0-8988-39303c3c2074.jpg[/img]
teacher表结构:
[img]http://dl.iteye.com/upload/attachment/592707/3369309f-4549-3e66-82d9-f7a264799361.jpg[/img]
student表结构:
[img]http://dl.iteye.com/upload/attachment/592709/e358e162-b3e0-3ef4-af1e-95875f84f542.jpg[/img]
package entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.TableGenerator;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Person {
private int id;
private String name;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package entity;
import javax.persistence.Entity;
@Entity
public class Teacher extends Person {
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
package entity;
import javax.persistence.Entity;
@Entity
public class Student extends Person {
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
}