JPA批注和接口

时间:2020-03-06 14:55:33  来源:igfitidea点击:

我有一个Animal类和一个从IAnimal继承的接口。

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

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

我的第一个问题是,我需要注释接口吗?

我问这个问题是因为在运行测试时出现此错误:

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

如果我没记错的话,在添加此界面之前,它已经开始工作了。

解决方案

发生此错误的原因是我们在查询中将动物拼写为普通的a。试试这个:

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

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

工作? (只是改变了动物的情况)