This post is pretty old but I am posting the solution just for fullness.
The problem is that you name your table with reserved name "user" in postgres. Hibernate will generate query that will not succeed:
Code:
select
user0_.id as id0_,
user0_.first_name as first2_0_,
user0_.last_name as last3_0_,
from
user user0_
This user in the from clause messes the things.
The work around is to specify your schema. Can be done in two ways (The solution is for post JPA 1 implementation)
1. By specifying the schema in the table in the @Table annotation. In case of schema public, will look like this.
Code:
@Entity
@Table(schema=”public”, name = “user”)
2. By specifying the schema in the schema in the persistence.xml
Code:
<property name="hibernate.default_schema" value="public"/>
This will crate a query that works:
Code:
select
user0_.id as id0_,
user0_.first_name as first2_0_,
user0_.last_name as last3_0_,
from
public.user user0_
Note that public.user in the FROM clause. This will work.
Hope that this one will help.