How to do GROUP BY dynamically?

From: Andreas Pardeike (andrea..ardeike.net)
Date: Thu Jan 06 2005 - 20:08:21 EST

  • Next message: Tore Halset: "cross-vm cache - group name?"

    Hi,

    currently, I am doing this

            Expression qual = Expression.fromString(Artjoina.FORFATTARE_PROPERTY +
    " <> ''");
            SelectQuery proto = new SelectQuery(Artjoina.class, qual);
            Map params = new HashMap();
            SelectQuery query = proto.queryWithParameters(params);
            return query;

    to get all FORFATTARE_PROPERTY out of Artjoina (which contains several
    fields). Now I want to only return unique entries but using setDistinct
    won't work because it only returns distinct rows (which will not be
    distinct if all fields are considered).

    I also want to change the code so it dynamically choose the field and
    optionally groups by it or not.

    Basically I need

    SELECT field_name FROM db GROUP BY field_name

    where field_name is dynamic. How would I do this? I can't and don't
    want to
    do this in the modeler.

    Regards,
    Andreas Pardeike



    This archive was generated by hypermail 2.0.0 : Thu Jan 06 2005 - 20:08:40 EST