我已升级到2.1版,并被迫从与投影配合使用的本机查询中移出。 所以现在当我尝试执行以下查询时:
@Query(value = "SELECT new com.core.model.CoreCountByDateQueryResult( DATE_FORMAT(s.detectedAt, '%Y-%m-%d') as datetime " +
", count(*)) "+
" from CoreSession s " +
" where s.uid.uid = :uid " +
" and s.sessionType = :sessionType " +
" and date( s.detectedAt ) >= :startDate" +
" and date( s.detectedAt ) <= :endDate " +
" group by datetime")
List<CoreCountByDateQueryResult> getSessionCountByType(@Param("uid") Long uid,
@Param("sessionType") SessionType sessionType,
@Param("startDate")Date startDate,
@Param("endDate") Date endDate);
@Data
public class CoreCountByDateQueryResult {
/**
* Watch time stamp
* @return watchTimeUTC
*/
private String datetime;
/**
* steps_count
* @return
*/
private long count;
public CoreCountByDateQueryResult(String datetime, long count) {
this.datetime = datetime;
this.count = count;
}
}
我收到未找到 datetime 的错误
java.sql.SQLSyntaxErrorException:“组语句”中的未知列“ datetime”
我该如何解决?