I’m using Spring boot, and I Run this model.
package com.example.demo.Models;
import jakarta.persistence.*;
@Entity
@Table(name = "user")
public class UserModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(unique = true, nullable = true)
private Long id;
private String name;
private String email;
private Integer priority;
/* Here are all the setters and getters*/
}
application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/dbdemo
spring.datasource.username=postgres
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
Everything fine with Java.
Process finished with exit code 0
But in the console of my docker image of Postgres I get the following error:
ERROR: syntax error at or near "user" at character 14
STATEMENT: create table user(id bigserial not null, email varchar(255), name varchar(255), priority integer, primary key (id))
I’m not sure how to solve it, I’d appreciate any help.
3
Answers
add the schema name before the table name
You need to specify the schema name in table and id fields like this:
user is a reserved word in Postgresql thats why it show an error
use a different word like "users" "usersId".