java Spring boot在创建表时出现“oracle.jdbc.OracleDatabaseException:ORA00904:invalid identifier”错误
在spring boot中,我使用代码优先的方法创建数据库表。 然后,在运行应用程序时,其中一个表的结果显示此错误:
WARN o.h.t.s.i.ExceptionHandlerLoggedImpl.handleException - GenerationTarget encountered exception accepting command : Error executing DDL "alter table statistic add date timestamp" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceExcepti
on: Error executing DDL "alter table statistic add date timestamp" via JDBC Statement]
oracle.jdbc.OracleDatabaseException: ORA-00904: : invalid identifier
类实体如下所示:
@Entity
@Table(name = "statistic")
public class Statistic {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String title;
private Long value;
private Date date;
private String unit;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getValue() {
return value;
}
public void setValue(Long value) {
this.value = value;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}
有人知道问题出在哪里吗
# 1 楼答案
这是错误的:
date
是Oracle数据类型的保留字。将列名更改为其他名称,例如datum
,c_date
,statistic_date
。。。然后跑