Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

22.hibernate继承映射joined

来源: xukongmoji 分享至:

person表结构:

teacher表结构:

student表结构:

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;
}

}

Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史