Sql запрос по себе отрабатывает отлично, но при вызове в методе executequery вылетает ошибка
'''
public List<TransactionReportModel> getAllExpensesId(long clientId, LocalDate
dateStart, LocalDate dataFinish) {
TransactionReportModel transactionReportModel;
List<TransactionReportModel> list = new ArrayList<>();
try (Connection connection = dataSource.getConnection()) {
String query = "select c.name, sum(t.transfer_amount)" +
"from category as c" +
"join transaction_to_category as ttc on ttc.type_id = c.id" +
"join transaction as t on t.id = ttc.transaction_id" +
"where c.client_id = ?" +
"and t.create_date between ? and ?" +
"group by (c.name)";
PreparedStatement ps = connection.prepareStatement(query);
ps.setLong(1, clientId);
ps.setDate(2, Date.valueOf(dateStart));
ps.setDate(3, Date.valueOf(dataFinish));
ResultSet rs = ps.executeQuery(query);
while (rs.next()) {
transactionReportModel = new TransactionReportModel();
transactionReportModel.setName(rs.getString(1));
transactionReportModel.setAmount(rs.getLong(2));
list.add(transactionReportModel);
}
ps.close();
} catch (SQLException e) {
//e.printStackTrace();
throw new CustomException(e);
}
return list;
}
'''