I\'m trying to declare a NamedQuery on a mapped superclass, but I obtain this error:
org.hibernate.hql.ast.QuerySyntaxException: VoipCall is not mappe
It is perfectly fine to have @NameQuery
annotation in @MappedSuperClass
. In past Hibernate used to had issue HHH-4364, which caused this to fail. Issue is fixed since years.
On the other hand query itself is not expected to work, because mapped superclass cannot be queried. In JPA 2.0 specification this is told with following words:
A mapped superclass, unlike an entity, is not queryable and must not be passed as an argument to EntityManager or Query operations.
This restriction kind of makes sense - purpose of mapped superclass is to share mappings between otherwise non-related entities, mapped superclass is not supposed to be root of the entity inheritance hierarchy. If such a query works, it is purely because of JPA vendor specific extension.