-
1. Re: How to use EntityQuery and aggregating functions for lists
sander Jun 3, 2008 9:04 PM (in response to keithbannister)If they are transient than this means they are not in the database and therefor cannot be ordered by the database, and thus via ejbql.
One option is to get the whole list and sort it on the server.
Downside is that you'd need to recalculate everything when sorting it, so you'd might run into performance prob's for large sets.Other option is to pre-calculate the stats and include them in the database just for performance reasons
-
2. Re: How to use EntityQuery and aggregating functions for lists
sander Jun 3, 2008 9:12 PM (in response to keithbannister)hmmz just read it again and your only using max/min/avg.
Since these are also just sql functions why not use these in the query.
I don't know exactly the ejbql notation but it could do.
You can also set them in the object via ejbql when using:
although i don't know if this is hibernate only function or just normal ejbqlSelect new Object(field1, field2, max(radio.source.field), min(..), etc) FROM ..
just make sure there is a correct constructor for it.
furthermore read some doc's about ejbql / hql first as this might not be syntax correct
-
4. Re: How to use EntityQuery and aggregating functions for lists
svadu Jun 3, 2008 10:22 PM (in response to keithbannister)I've had a similar problem but with much more complex business rules and somewhat big database (few mill records) so the performance impact would be severe.
I've decided to define pre-calculated values at RadioSource (in your case) and used an EntityListener which listens for PrePersist and PreUpdate where I calculate and set the values and this did the job for me.