java – Syntax error when creating table in PostgreSQL using Hibernate


public class User {
    private int id;
    private String name;
    private String email;
    private String sex;
    private int age;
    private Date birthday;
    private Date registerdate;
    private String login;
    private String password;
    @JoinTable(name = "eventlike_user", joinColumns = @JoinColumn(name = "id_user"), inverseJoinColumns = @JoinColumn(name = "id_eventlike"))
    private Collection<Eventlike> eventlikes;
    private Collection<Event> events;

   //getters and setters

I get the following error when creating the tables:

ERROR: HHH000388: Unsuccessful: create table User (id int8 not null, birthday timestamp, email varchar(255), login varchar(255), name varchar(255), password varchar(255), registerdate timestamp, sex varchar(255) , primary key (id)) Nov 12, 2014 10:55:33 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute ERROR: ERROR: syntax error at or near "User" Position: 14

I don't know what is causing this table not to be created but what catches my attention is this int8 type of id .


This error happens because accented characters, capital letters and reserved words must be escaped with double quotes " . In your case user is a reserved word. According to this SOen answer your annotation should look like this:

For JPA 1.0

public class User {

JPA 2.0

public class User {
Scroll to Top