@Table(name = "t_foodtype")
@Entity
public class FoodType implements IEntity<Integer> {
private static final long serialVersionUID = -2542562223727790555L;
//默认初始化有早餐、午餐、晚餐、夜宵、饮料,然后其id默认是1、2、3、4、5,因为是全部学校共用的,所以schoolid为0
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
//菜式分类的名称,比如早餐、午餐、晚餐、夜宵、饺子、麻辣烫等,默认初始化有早餐、午餐、晚餐、夜宵、饮料
@Column(length = 16, nullable = false, name = "name")
private String name;
//0为主食、1为零食、2为日用品
@Column(nullable = true, name = "type")
private Integer type;
//0为不显示,1或null为显示
@Column(nullable = true, name = "noshow")
private Integer noshow;
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, mappedBy = "foodType")
private Set<Food> foods;
//学校id
@Column(nullable = false, name = "schoolid")
private Integer schoolId;
//菜式卡列表中展示的图片
@Column(length = 256, nullable = true, name = "path")
private String path;
//根据这个条件来排序再copy插入新学校的菜式卡列表
@Column(nullable = true, name = "orderid")
private Integer orderid;
public FoodType() {
}
public FoodType(String name, Integer type, Integer noshow, Integer schoolId) {
super();
this.name = name;
this.type = type;
this.noshow = noshow;
this.schoolId = schoolId;
}
public FoodType(String name, Integer type, Integer noshow, Set<Food> foods,
Integer schoolId, String path) {
super();
this.name = name;
this.type = type;
this.noshow = noshow;
this.foods = foods;
this.schoolId = schoolId;
this.path = path;
}
public FoodType(String name, Integer type, Integer noshow, Set<Food> foods,
Integer schoolId, String path, Integer orderid) {
super();
this.name = name;
this.type = type;
this.noshow = noshow;
this.foods = foods;
this.schoolId = schoolId;
this.path = path;
this.orderid = orderid;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Set<Food> getFoods() {
return foods;
}
public void setFoods(Set<Food> foods) {
this.foods = foods;
}
public Integer getSchoolId() {
return schoolId;
}
public void setSchoolId(Integer schoolId) {
this.schoolId = schoolId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Integer getNoshow() {
return noshow;
}
public void setNoshow(Integer noshow) {
this.noshow = noshow;
}
public Integer getOrderid() {
return orderid;
}
public void setOrderid(Integer orderid) {
this.orderid = orderid;
}
}
主要你得明白各个注解的意思,这样子自己很容易就能知道实体类对应的表结构了。
drop table if exists t_foodtype;
create table t_foodtype
(
id int not null,
name varchar(16) not null,
type int,
noshow int,
schoolid int not null,
path varchar(256),
orderid int,
primary key (id)
);
你看有哪些字段 字段类型 不就可以了 。。。
还有 你这个是hibernate生成的吧!