Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate spring数据jpa超级类字段选择查询_Hibernate_Jpa_Jpa 2.0_Spring Data - Fatal编程技术网

Hibernate spring数据jpa超级类字段选择查询

Hibernate spring数据jpa超级类字段选择查询,hibernate,jpa,jpa-2.0,spring-data,Hibernate,Jpa,Jpa 2.0,Spring Data,我有一个超类(不是@实体或@MappedSuperClass)和子类entty类,如: Class A { @ElementCollection protected Collection<SomeEntity> someEntities; // getter and setter } 我编写了自定义查询来选择名称和一些实体,如: @Query ("select b.name, b.someEntities from B b") 它在运行时抛出一个异常,表示无法识别的

我有一个超类(不是
@实体
@MappedSuperClass
)和子类entty类,如:

Class A {
   @ElementCollection
   protected Collection<SomeEntity> someEntities;

// getter and setter
}
我编写了自定义查询来选择名称和一些实体,如:

@Query ("select b.name, b.someEntities from B b")
它在运行时抛出一个异常,表示无法识别的字段someEntities


如果我犯了错误,有什么解决办法吗

如果您的超类不是
@Entity
@MappedSuperclass
(有什么原因吗?),那么其中声明的任何字段都不是持久的,不知道是否休眠,也不能在查询中使用。如果您提供一个用例,它可以帮助我们提供一个替代方案

@Query ("select b.name, b.someEntities from B b")