Zeemee
Zeemee

Reputation: 10714

What could cause a QuerySyntaxException: [Entity] is not mapped, although the entity has been bound?

I wonder why I get QuerySyntaxException: [Entity] is not mapped, although Hibernate is logging

INFO Hibernate EntityManager 3.5.0-Final
...
INFO Binding entity from annotated class: products.model.ProductGroup
INFO Bind entity products.model.ProductGroup on table GRP
...
INFO table found: GRP
INFO columns: [grp, name, top]

The entity class looks like

@Entity(name="GRP")
public class ProductGroup implements IdentifiableEntity {

    @Id
    private String grp;
    private String name;
    private String top;

    ...
}

The error is thrown at this line:

Query q = em.createQuery("select g from ProductGroup g");

It is all JPA, no Hibernate API.

Upvotes: 3

Views: 5078

Answers (1)

Kurt Du Bois
Kurt Du Bois

Reputation: 7665

@Entity(name) sets the internal name of the entity for JPA. Try removing that statement and work with an @Table(name = "GRP")

If that doesn't work, please post the complete stacktrace.

Upvotes: 7

Related Questions