hi david,

you'll have to use report queries to get calculated columns.

ReportQueryByCriteria query;
Criteria crit;


       crit = new Criteria();
       crit.addLike("name", "%er");
       query = new ReportQueryByCriteria(Person.class, crit);
       query.setColumns(new String[]{"firstname", "sum(test)" });
       broker.getReportQueryIteratorByQuery(query);

this query returns an array of "rows" (an array of objects) where the first object contains the "firstname" and the second the sum.
report queries do not return full blown business objects. for further examples have a look at the testcases in QueryTest.


hth
jakob

David Warnock wrote:

Hi,

I have read the docs, looked at the tests but I can't quite grasp how to get the calculated columns eg Max, Sum, Count.

eg I have

<class-descriptor
  class="com.sundayta.balloons.model.implementation.Items"
  table="Items"
>
  <field-descriptor
    name="itemId"
    column="ItemId"
    jdbc-type="INTEGER"
    primarykey="true"
    autoincrement="true"
    sequence-name="GEN_ItemId"
  />
  <field-descriptor
    name="rowVersion"
    column="RowVersion"
    jdbc-type="INTEGER"
    locking="true"
  />
  <field-descriptor
    name="Name"
    column="Name"
    jdbc-type="VARCHAR"
  />
  <field-descriptor
    name="value"
    column="Value"
    jdbc-type="NUMERIC"
  />
</class-descriptor>

I want to be able to find the following

a) Max RowVersion value

b) A List of distinct Names with the number of instances of each name

c) The sum of all the value's for each distinct name

I think I want to be using a ReportQuery.getCollectionByCriteria. But what I don't understand is

1. The relationship between the ReportQuery.setColumns and the Items class

2. When I get a Collection back what it actually contains and how I work with that.

Sorry if this is a bit basic, but thanks for your help.



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to