在 Spring 3 应用程序中,控制器调用 JpaCollectorManager 并调用 JpaCollectorInfoDao 以获取由 nativequery 定义的列表。该查询调用了 2 个使用 sql 和 jpql 的单独表,因为我需要使用 jpql 中未实现的 postgresql 功能。当控制器尝试归档列表时,我收到以下错误消息:
异常 [EclipseLink-6007] (Eclipse Persistence Services - 2.1.2.v20101206-r8635):org.eclipse.persistence.exceptions.QueryException 异常描述:缺少 [CollectorInfo] 的描述符。
查询:ReadAllQuery(referenceClass=CollectorInfo sql="select distinct ON (col.collector_id,pst.process_source_type) col.*,pst.process_source_timestamp,pst.process_source_type from perform_schema.collector col join perform_schema.process_set pst on pst.collector_id = col. collector_id order by col.collector_id, pst.process_source_type,pst.process_source_timestamp desc ")
控制器 Java 有以下调用:
List<CollectorInfo> ps = this.collectorInfoManager.getLatestCollectorInfo();
JpaCollectorInfoManager.java 有这个:
public List<CollectorInfo> getLatestCollectorInfo()
{
return collectorInfoDao.getLatestCollectorInfo();
}
JpaCollectorInfoDao.java:
@Override
@Transactional
public List<CollectorInfo> getLatestCollectorInfo() {
Query query = entityManager.createNativeQuery( ( "select distinct ON ( col.collector_id," +
"pst.process_source_type ) " +
"col.*," +
"pst.process_source_timestamp," +
"pst.process_source_type " +
"from perform_schema.collector col " +
"join perform_schema.process_set pst " +
"on pst.collector_id = col.collector_id " +
"order by col.collector_id, " +
"pst.process_source_type," +
"pst.process_source_timestamp desc " ),
CollectorInfo.class );
return ( (List<CollectorInfo>) query.getResultList() );
}
CollectorInfo 类没有定义@Entity。如果我设置了 @Entity 定义,那么它告诉我无法解析表(这是正确的,因为没有实际的表)。我尝试了各种排列,似乎无法制作这条针线。