I'm trying to declare a NamedQuery on a mapped superclass, but I obtain this error:
org.hibernate.hql.ast.QuerySyntaxException: VoipCall is not mapped [select v from VoipCall v where v.audioFile = :audioFile]
We use hibernate, but we prefer to use JPA standard notation.
Here is the code:
@MappedSuperclass
@NamedQueries(value = {
@NamedQuery(name = "getVoipCallsForAudio", query = "select v from VoipCall v where v.audioFile = :audioFile")
})
public abstract class VoipCall implements Serializable {
It seems that I cannot use my mappedSuperClass in the query, but I don't understand why if in the JPA API I found this:
The NamedQuery annotation can be applied to an entity or mapped superclass.
Where am I wrong?
Thanks!!
SOLUTION: The solution for me was a workaround: I moved the named query on the subclasses changing the where clause opportunely. This from my point of view give me less maintainability of code, but I cannot do in another way.