我想使用此查询在Data Spring中实现SQL查询:
public List<PaymentTransactionsDailyFacts> findPaymentTransactionsDailyFacts(LocalDateTime start_date, LocalDateTime end_date) {
String hql = "SELECT DATE(date) AS Date, SUM(volume) AS amount, COUNT(*) AS number_of_transactions " +
" FROM " + PaymentTransactionsDailyFacts.class.getName() + " WHERE (date BETWEEN :start_date AND :end_date )" +
" GROUP BY DATE(date)";
TypedQuery<PaymentTransactionsDailyFacts> query = entityManager.createQuery(hql, PaymentTransactionsDailyFacts.class).setParameter("start_date", start_date).setParameter("end_date", end_date);
List<PaymentTransactionsDailyFacts> data = query.getResultList();
return data;
}
但是我得到这个错误:
01:23:16,208 INFO [stdout] (default task-1) 01:23:16.206 [default task-1] ERROR o.s.b.w.s.support.ErrorPageFilter - Forwarding to error page from request [/dashboard/volumes/USD] due to exception [Cannot create TypedQuery for query with more than one return using requested result type [org.datalis.plugin.entity.PaymentTransactionsDailyFacts]]
01:23:16,208 INFO [stdout] (default task-1) java.lang.IllegalArgumentException: Cannot create TypedQuery for query with more than one return using requested result type [org.datalis.plugin.entity.PaymentTransactionsDailyFacts]
01:23:16,208 INFO [stdout] (default task-1) at deployment.datalis_admin.war//org.hibernate.internal.AbstractSharedSessionContract.resultClassChecking(AbstractSharedSessionContract.java:783)
01:23:16,208 INFO [stdout] (default task-1) at deployment.datalis_admin.war//org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:730)
您知道我该如何解决这个问题?