将查询结果导出到自定义dto时出错

时间:2018-03-18 10:30:36

标签: java spring jpa spring-boot

查询

@Query(value = "SELECT new com.fin.iota.model.dto.TimeSeriesDto(date_trunc('hour', PC.time), sum(PC.count)) from UserCount as PC where PC.time >= :currentDate and PC.time < :nextDate group by date_trunc('hour', PC.time)")
    List<TimeSeriesDto> generateTimeSeries(@Param("currentDate") Timestamp currentDate, @Param("nextDate") Timestamp nextDate);

DTO

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TimeSeriesDto {
    Date dayHour;
    long pcounts;
}

错误

Error creating bean with name 'userCountDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.fin.iota.repository.user.UserCountDao.generateTimeSeries(java.sql.Timestamp,java.sql.Timestamp)!

我错过了什么或者什么是不正确的?

0 个答案:

没有答案