[sending this back to the list]
> On 7 jan 2005, at 15.25, Andrus Adamchik wrote:
>
>> Adding GROUP BY would change object "identity", as you group multiple
>> DB
>> rows into one result row. So strictly speaking the returned result
>> won't
>> be a Artjoina instance anymore and using SelectQuery won't work.
>
> Meanwhile, I got to the same impression especially after discussing the
> issue with my friend Anjo from Germany (he knows EOF & WO pretty good).
>
> Still, I am trying to see a group by as a way to restrict the result
> set. Maybe it's better to talk about distinct here. The problem I have is
> that I cannot use setDistinct because it always works on the whole row and
> not as I want it on one or several fields only.
Say hi to Anjo ;-)
While "GROUP BY" would do the trick, it still doesn't look right. It is
normally used for *aggregating* data for one or more columns across
multiple rows. If there is no aggregation (such as SUM, AVG, COUNT, etc.),
there is no need to GROUP BY.
If you need to use DISTINCT for a subset of columns, you can do just that
- use only relevant columns in SELECT DISTINCT. Your example hints that
you probably care about that subset of columns, and can ignore the rest.
If this is the case, you can map ObjEntity to exclude columns that you
don't need, and then a normal SelectQuery would work.
> I tried SQLTemplate but my problem is that I am using Tapestry's..able
> in my
> own component where I pass a full SelectQuery in and let the table
> component
> handle the sorting. And from what I can see, it's impossible to add
> sorting "afterwards" to a SQLTemplate.
>
> Any suggestion?
If the one above doesn't work... don't forget that SQLTemplate is a
Velocity script, so in addition to Cayenne-specific directives (#bind,
#result...) you can use any other Velocity scripting facilities -
variables, conditionals, etc. So you can script ordering as a template
variable and set it dynamically.
> What I am doing right now, is to create views in DB2 (btw, is this
> possible from within the modeler *only* ?)
> and use those pre-group by tables instead.
No, the Modeler can map a view, but doesn't keep its definition. This
maybe added in the future.
> I do loose
> the dynamic aspect though and in the long run I might have a problem
> writing my data mining tool that I intend to write.
>
> I guess I am abusing cayenne here a bit since it's main purpose is to
> flexible store objects and not to process huge chunks of data in any
> possible way.
Well, yeah... Massaging the data is better done by the DB itself. Still
SQLTemplate is powerful enough to define ad-hoc SQL operations that are
not tied to the object model at all.
Andrus
This archive was generated by hypermail 2.0.0 : Fri Jan 07 2005 - 15:09:50 EST