I’m using Postgres via Hibernate (annotations), but it seems to be falling over dealing with a User object:
12:09:16,442 ERROR [SchemaExport] Unsuccessful: create table User (id bigserial not null, password varchar(255), username varchar(255), primary key (id))
12:09:16,442 ERROR [SchemaExport] ERROR: syntax error at or near "User"
If I run the SQL manually I have to put quotes around the table name as user seems to be a postgres keyword, but how can I convince hibernate to do this itself?
Thanks in advance.
You need to escape the table name when using reserved keywords. In JPA 1.0, there is no standardized way and the Hibernate specific solution is to use backticks:
In JPA 2.0, the standardized syntax looks like this:
References