June 19, 2012

org.hibernate.hql.ast.QuerySyntaxException

Description: org.hibernate.hql.ast.QuerySyntaxException: Tablename is not mapped [SELECT id
FROM Tablename] when trying to run NamedQuery in JPA. 



Reason/Solution: Put simply, you are using the table name instead of the Entity class name mapped in persistence.xml. 


So if table USERS is mapped to entity class User, your query will need User and not USERS. 



No comments: