I want to count the several rows using JPA.
My Code:
String hql = "SELECT count(e.id) as count, e.status, e.error_class, e.error_message, e.id, e.settlement_status_raw FROM " + PaymentTransactions.class.getName() + " e WHERE e.terminal_id = :terminal_id AND (e.createdAt > :created_at) AND (e.status != 'approved') GROUP BY e.error_message ORDER BY count DESC";
TypedQuery<PaymentTransactions> query = entityManager.createQuery(hql, PaymentTransactions.class).setParameter("terminal_id", terminal_id).setParameter("created_at", created_at);
List<PaymentTransactions> paymentTransactions = query.getResultList();
return paymentTransactions;
But I got an error:
Caused by: org.hibernate.QueryException: could not resolve property: DESC.
Count is not present into the entity but I want to return it as a value. What is the proper way to implement this?
In Query,after Orderby only specify the column name like,