【发布时间】:2016-01-27 03:16:47
【问题描述】:
在我的 Spring 应用程序中,我有一个名为 Resource::
的实体@Entity
public class Resource {
List<Resource> list = em.createNativeQuery("select r.* from ...", Resource.class).getResultList();
出于一个特定目的,我需要在结果中添加更多字段。所以我创建了一个子类ExtendedResource:
@Entity
public class AreaResource extends Resource {
@Column(name="extra_field")
private Integer extra field;
List<ExtendedResource> list = em.createNativeQuery("select extra_field, r.* from ...", ExtendedResource.class).getResultList();
当我查询 ExtendedResource 时,这很好用,但是对于我得到的资源:
org.postgresql.util.PSQLException: The column name DTYPE was not found in this ResultSet.
有什么办法可以解决这个问题,而不用担心鉴别器列吗?我猜MappedSuperclass 是一个解决方案,但我想避免制作额外的课程。
谢谢
【问题讨论】:
标签: java spring hibernate postgresql jpa