错误信息:Table ‘sell.hibernate_sequence‘ doesn‘t exist
错误原因:实体主键没有配置主键自增长
错误写法:
package com.itcast.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicUpdate;
import lombok.Data;
/**
* 商品类目实体
* @author jack
*
*/
@Entity
@DynamicUpdate
@Data
public class ProductCategory {
/**类目id*/
@Id
@GeneratedValue
private Integer categoryId;
/**类目名称*/
private String categoryName;
/**类目编号*/
private Integer categoryType;
public ProductCategory(){}
public ProductCategory(String categoryName, Integer categoryType) {
this.categoryName=categoryName;
this.categoryType=categoryType;
}
/*
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getCategoryType() {
return categoryType;
}
public void setCategoryType(String categoryType) {
this.categoryType = categoryType;
}
@Override
public String toString() {
return "ProductCategory [categoryId=" + categoryId + ", categoryName=" + categoryName + ", categoryType="
+ categoryType + "]";
}
*/
}
正确写法
package com.itcast.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicUpdate;
import lombok.Data;
/**
* 商品类目实体
* @author jack
*
*/
@Entity
@DynamicUpdate
@Data
public class ProductCategory {
/**类目id*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer categoryId;
/**类目名称*/
private String categoryName;
/**类目编号*/
private Integer categoryType;
public ProductCategory(){}
public ProductCategory(String categoryName, Integer categoryType) {
this.categoryName=categoryName;
this.categoryType=categoryType;
}
/*
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getCategoryType() {
return categoryType;
}
public void setCategoryType(String categoryType) {
this.categoryType = categoryType;
}
@Override
public String toString() {
return "ProductCategory [categoryId=" + categoryId + ", categoryName=" + categoryName + ", categoryType="
+ categoryType + "]";
}
*/
}
网友评论