springboot中实体定义的SQL语法错误

问题描述 投票:0回答:1

我将 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]

我的实体定义有什么问题?

postgresql spring-boot hibernate jpa
1个回答
0
投票

有这个问题。 'user' 是 postgresql 中的关键字,因此出现问题。

将“suer”更改为其他内容解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.