我将 JPA 实体定义为:
@Entity
@Table(name="User")
public class User {
@Id
private String id;
private String email;
private String name;
@Temporal(TemporalType.DATE)
private Date dateOfCreation;
public User(){}
public User(String id, String email, String name) {
this.id = id;
this.email = email;
this.name = name;
this.dateOfCreation = new Date();
}
}
但是它出现sql语法错误:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
create table user (
date_of_creation date,
email varchar(255),
id varchar(255) not null,
name varchar(255),
primary key (id)
)" via JDBC [ERROR: syntax error at or near "user"
Position: 19]
我的实体定义有什么问题?
有这个问题。 'user' 是 postgresql 中的关键字,因此出现问题。
将“suer”更改为其他内容解决了问题。