Код: Выделить всё
@Query(value =
"select sum(txd.unit_amount) as amount, (0.9) as price, t.course as course " +
" from transactions t " +
" join transaction_x_details txd on t.id = txd.transaction_id " +
" join accounts a on t.account_id = a.id " +
" where a.id = :accountId " +
" and t.operation_type = 10 " +
" and t.created_at between :dateFrom and :dateTo " +
" group by course ",
nativeQuery = true)
List findAllFromXByAccountIdAndPeriod(Long accountId, LocalDateTime dateFrom, LocalDateTime dateTo);
Код: Выделить всё
public interface XQuery {
Long getAmount();
BigDecimal getPrice();
BigDecimal getCourse();
}
Код: Выделить всё
@Query(value =
"select \"xQuery\", \"customerInn\" " +
"from (select sum(txd.unit_amount) as amount, (p.value * t.course) as price, cs.inn as \"customerInn\" " +
" from transactions t " +
" join transaction_x_details txd on t.id = txd.transaction_id " +
" join accounts a on t.account_id = a.id " +
" join categories ct on ct.id = a.category_id " +
" join customers cs on cs.id = a.customer_id " +
" join prices p on ct.price_id = p.id " +
" where a.id in (:accountsId) " +
" and t.operation_type = 10 " +
" and t.created_ts between :dateFrom and :dateTo " +
" group by price, \"customerInn\") as \"xQuery\" " +
"group by \"xQuery\", \"customerInn\" ",
nativeQuery = true)
List findAllFromXByPeriodAndAccountIdIn(List accountsId,
LocalDateTime dateFrom,
LocalDateTime dateTo);
Код: Выделить всё
public interface XPackageQuery {
List getXQueries();
String getCustomerInn();
}
- xQueries: всегда null;
- customerInn: правильно.
Примечания:
- выполнил запрос напрямую , данные верны;
- Ошибок в клиентском коде точно нет.
Подробнее здесь: https://stackoverflow.com/questions/784 ... ons-in-jpa
Мобильная версия