今天做东西的时候想用jpa实现商品的repository,有四个表,goods,goods_image,goods_type,goods_and_image
goods与goods_image为一对多关系,goods_image中存放goods_id和image,一个goods_id可以有多个Image;
goods与goods_type为多对多关系,goods_and_type存放goods_id和goods_type,每个goods_id可以有多种type,每
个type也是有多种商品;
数据表
create table goods
(
id int auto_increment
primary key,
name varchar(50) not null,
description varchar(255) null,
price int not null,
status int default '0' null,
create_time timestamp default CURRENT_TIMESTAMP not null,
num int null
);
create table goods_image
(
`_id` int auto_increment
primary key,
goods_id int not null,
remark varchar(255) null,
image varchar(255) not null
);
create table type
(
type_id int auto_increment
primary key,
name varchar(100) null,
parent int default '0' not null
comment '父类别 0代表顶级类别'
);
create table goods_and_type
(
id int auto_increment
primary ke