Actually the solution was @Formula Hibernate fields.
For example:
@XmlTransient
@Formula("(select sum(invoices.amountdue) from invoices where
invoices.event_id = event_id and invoices.participant_id = participant_id)")
private Double amountInvoiced;
PostgreSQL is able to optimize i
Ilya,
I haven't faced that situation… yet. I guess the complication is in
specifying the grouping conditions.
My stats listings are restricted in size, so I don't worry about a
paged grid source for those, and I get the results from stored
procedures. Some of the *counts* in that list are large
I have ended up with custom DTO classes and Hibernate projections. Although
the resulting code looks far from elegant, it's extremely fast, compared to
'normal' retrieval using lists, without paging (especially for lists with
hundreds of records of course).
On Mon, Jan 5, 2015 at 1:39 PM, Thiago H
On Fri, 02 Jan 2015 06:45:30 -0200, Ilya Obshadko
wrote:
I'm trying to implement a Grid data source optimized for database
retrievals (with paging support). Basically it's derived from
HibernateGridDataSource from Tapestry distribution, and provides support
for complex Criteria queries:
https
Johnathan,
How do you handle situations when several of the properties you need to
display are aggregates?
For example: select ..., sum(amount_invoiced), sum(amount_paid) from orders
group by order_id.
This won't work nice with Projections.rowCount() (unless you use
sub-select, which might be sub
Ilya,
Our strategy is to use a class specifically to hold the query results,
so the sort criteria are simple properties. The Criteria query and
Projection are supplied separately to our GridDataSource. The
Projection maps any child properties onto aliases (useful for the
sorting), and an option
The automatic creation of bean models can only do so much - I always find
that the automatic model creation is great for getting started, but at some
point it is always necessary to provide explicit bean models.
The pattern we end up with is something like this:
model = beanModelSource.createDisp