Search code examples
jpajava-ee-5

JPA annotations and Interfaces


I have a class Animal and an interface it inherits from IAnimal.

@MappedSuperclass
public class Animal implements Serializable, IAnimal{...}.

@Entity
public class Jaguar extends Animal{...}

My first question is, do I need to annotate the interface?

I asked this because I am getting this error when I run my tests:

Error compiling the query [SELECT s FROM animal s WHERE s.atype = :atype]. Unknown abstract schema type [animal]

If I remember correctly, before I added this interface it was working.


Solution

  • This error is occurring because you spelled Animal with a common a in the query. Try this:

     SELECT s FROM Animal s WHERE s.atype = :atype