das*_*001 3 ddl hibernate jpa create-table spring-boot
我想保存一些来自请求的数据。为此,我创建了一些实体类。但为什么我会出现这个异常?
Error executing DDL "create table body_datum (body_datum_id integer not null, key varchar(255), value varchar(255), value_type varchar(255), primary key (body_datum_id)) engine=InnoDB" via
Run Code Online (Sandbox Code Playgroud)
这是我的属性。
spring.datasource.url= jdbc:mysql://localhost:3306/loadtestdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create
Run Code Online (Sandbox Code Playgroud)
这是我的模型课程。
@Data
@Entity
public class BodyDatum {
@Id
@GeneratedValue
private Integer bodyDatumId;
private String key;
private String value;
private String valueType;
}
Run Code Online (Sandbox Code Playgroud)
产品类别是这样的
@Data
@Entity
public class Product {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long pId;
private String productName;
private int pQty;
private int price;
@ManyToOne
@JoinColumn(name = "customer_id")
private Customer customer;
}
Run Code Online (Sandbox Code Playgroud)
在数据库中,Product 表已创建。
为什么会出现这样的错误?
谢谢。
我认为属性“key”是SQL的保留字。像这样重命名你的属性:
@Data
@Entity
public class BodyDatum {
@Id
@GeneratedValue
private Integer bodyDatumId;
private String bodyDatumkey;
private String value;
private String valueType;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27689 次 |
| 最近记录: |