实体商品示例代码
package cn.maxhou.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity//该注解表名该类为一个实体
public class Goods implements Serializable {
private static final long serialVersionUID = 5060150518287868308L;
@Id//id注解
@GeneratedValue(strategy=GenerationType.IDENTITY)//ID自增注解
private int id;
private String name;
private String specifications;
private BigDecimal price;
private int quantity;
@ManyToOne//表名商品和分类的关系是多对一
@JoinColumn(name = "classification_id")//设置加入类名
private Classification classification;
public Goods() {
}
public Goods(String name, String specifications, BigDecimal price, int quantity) {
super();
this.name = name;
this.specifications = specifications;
this.price = price;
this.quantity = quan