У меня JpaRepository :
@Repository
public interface CardReaderRepository extends JpaRepository<CardReaderEntity, Integer > {
}
, когда я выполняю запрос в этом репо так же, как это:
@Query(
value = "SELECT new ir.server.component.panel.response." +
"InvalidCardReaderDataDigestResponse(" +
" cr.driverNumber, cr.exploiterCode, cr.lineCode, " +
" cr.transactionDate, cr.offLoadingDate, " +
" cr.cardReaderNumber, " +
" sum(cr.count) , sum(cr.remind) " +
") " +
"FROM CardReaderEntity cr " +
"WHERE cr.company.id = :companyId " +
"AND cr.status.id in :statusIds " +
"AND cr.deleted = false " +
"AND (:fromDate is null or cr.offLoadingDate >= :fromDate ) " +
"AND (:toDate is null or cr.offLoadingDate <= :toDate ) " +
"group by cr.driverNumber, cr.exploiterCode, cr.lineCode, cr.transactionDate, cr.offLoadingDate, cr.cardReaderNumber"
)
Page<InvalidCardReaderDataDigestResponse> findAllInvalidCardReaderDataDigestByCompanyIdAndStatusIdIn(
@Param( "companyId" ) int companyId,
@Param( "fromDate" ) Date fromDate,
@Param( "toDate" ) Date toDate,
@Param( "statusIds" ) List<Integer> statusIds,
Pageable pageable
);
ошибка:
org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $3
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306) ~[postgresql-42.2.2.jar:42.2.2]
но при изменении запроса на:
@Query(
value = "SELECT new ir.server.component.panel.response." +
"InvalidCardReaderDataDigestResponse(" +
" cr.driverNumber, cr.exploiterCode, cr.lineCode, " +
" cr.transactionDate, cr.offLoadingDate, " +
" cr.cardReaderNumber, " +
" sum(cr.count) , sum(cr.remind) " +
") " +
"FROM CardReaderEntity cr " +
"WHERE cr.company.id = :companyId " +
"AND cr.status.id in :statusIds " +
"AND cr.deleted = false " +
"AND (:fromDate is null ) " +
"AND (:toDate is null ) " +
"group by cr.driverNumber, cr.exploiterCode, cr.lineCode, cr.transactionDate, cr.offLoadingDate, cr.cardReaderNumber"
)
Page<InvalidCardReaderDataDigestResponse> findAllInvalidCardReaderDataDigestByCompanyIdAndStatusIdIn(
@Param( "companyId" ) int companyId,
@Param( "fromDate" ) Date fromDate,
@Param( "toDate" ) Date toDate,
@Param( "statusIds" ) List<Integer> statusIds,
Pageable pageable
);
эта работа без ошибок, но при желании выполнить с fromDate и toDate
примечание:
offLoadingDate in CardReaderEntity :
@Basic
@Temporal( TemporalType.TIMESTAMP )
public Date getOffLoadingDate() {
return offLoadingDate;
}
public void setOffLoadingDate(Date offLoadingDate) {
this.offLoadingDate = offLoadingDate;
}
все данные о дате импорта в моих файлах java составляют java.util.Date.