一、每个子类对应一个数据表(Table per concrete class)
学生表
create table `sample`.`student`(
`id` bigint not null auto_increment,
`name` varchar(20) default '' not null,
`score` float,
);
create unique index `PRIMARY` on `sample`.`student`(`id`);
教师表
create table `sample`.`teacher`(
`id` bigint not null auto_increment,
`name` varchar(20) default '' not null,
`salary` float(6,2),
primary key (`id`)
);
create unique index `PRIMARY` on `sample`.`teacher`(`id`);
Person抽象基类
public abstract class Person
implements java.io.Serializable {
private Long id;
private String name;
/**defaultconstrUCtor*/
public Person() {