I can create a record from an entity without problems. But I want to create a report from a datasource, which I use to show the entries in a table in cuba. The logic is made in the backend and sended to cuba via rest.
Suppose you have a service that selects some order on a certain condition, for example:
@Service(ReportDataService.NAME)
public class ReportDataServiceBean implements ReportDataService {
@Inject
private Persistence persistence;
@Override
public List<Order> getTodaysOrders() {
Query query = persistence.getEntityManager().createQuery(
"select o from sales$Order o where @between(o.createTs, now, now+1, day)");
return query.getResultList();
}
}
The same result can be easily achieved with List of entities selected by query dataset, where the query is the following:
select
e.amount as "amount",
customer.name as "customer.name",
e.date as "date"
from sales$Order e
left join e.customer customer
where @between ( e.createTs, now, now + 1, DAY)