錯(cuò)誤信息:Table ‘sell.hibernate_sequence‘ doesn‘t exist
錯(cuò)誤原因:實(shí)體主鍵沒(méi)有配置主鍵自增長(zhǎng)
錯(cuò)誤寫法:
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;
/**
* 商品類目實(shí)體
* @author jack
*
*/
@Entity
@DynamicUpdate
@Data
public class ProductCategory {
/**類目id*/
@Id
@GeneratedValue
private Integer categoryId;
/**類目名稱*/
private String categoryName;
/**類目編號(hào)*/
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;
/**
* 商品類目實(shí)體
* @author jack
*
*/
@Entity
@DynamicUpdate
@Data
public class ProductCategory {
/**類目id*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer categoryId;
/**類目名稱*/
private String categoryName;
/**類目編號(hào)*/
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 + "]";
}
*/
}