i'm trying declare namedquery on mapped superclass, obtain error:
org.hibernate.hql.ast.querysyntaxexception: voipcall not mapped [select v voipcall v v.audiofile = :audiofile]
we use hibernate, prefer use jpa standard notation.
here code:
@mappedsuperclass @namedqueries(value = { @namedquery(name = "getvoipcallsforaudio", query = "select v voipcall v v.audiofile = :audiofile") }) public abstract class voipcall implements serializable { it seems cannot use mappedsuperclass in query, don't understand why if in jpa api found this:
the namedquery annotation can applied entity or mapped superclass.
where wrong?
thanks!!
solution: solution me workaround: moved named query on subclasses changing clause opportunely. point of view give me less maintainability of code, cannot in way.
it fine have @namequery annotation in @mappedsuperclass. in past hibernate used had issue hhh-4364, caused fail. issue fixed since years.
on other hand query not expected work, because mapped superclass cannot queried. in jpa 2.0 specification told following words:
a mapped superclass, unlike entity, not queryable , must not passed argument entitymanager or query operations.
this restriction kind of makes sense - purpose of mapped superclass share mappings between otherwise non-related entities, mapped superclass not supposed root of entity inheritance hierarchy. if such query works, purely because of jpa vendor specific extension.
Comments
Post a Comment