Thanks for all responses so far. It looks like I did leave out one very important clarification.
For CarInfo, the getWeight method is coded by me. Since CarCustomizationsInfo is optional, the base weight will come from either there or from the CarModelInfo class. Taking the base weight, the total weight is then calculated by adding all of the individual CarAddedParts weights. So.... I do not know of any way to do this using the reports stuff. At least, not without shooting myself in the foot when it comes to readability. (I had thought to do a custom SQL to accomplish this, but the logic there makes it more than a simple select, so I've ditched that idea as my bosses don't want stored procs.) To clarify: If a CarInfo has a CarCustomizationInfo, then the base weight comes from there; otherwise, the base weight comes from the CarModelInfo. This is what keeps me from being able to use an OJB report (or a single select, for that matter). -josh Charles Anthony <[EMAIL PROTECTED]> wrote: > Bugger. It's too late to be in the office, it's hot and I'm tired. > I'll try again : > > PersistenceBroker broker = ...; > Long customerId = new Long(1); > > /* Query/Select 1 : gets all the car parts for the customer */ > Criteria c1 = new Criteria(); > c.addEqualTo("carModelInfo.carInfo.invoice.customer.id", customerId); > Query q1 = new QueryByCriteria(CarAddedParts.class, c); > Collection parts = broker.getCollectionByQuery(q1); > > /* Query/Select 2 : gets all the modelInfos for the customer */ > Criteria c2 = new Criteria(); > c.addEqualTo("carInfo.invoice.customer.id", customerId); > Query q2 = new QueryByCriteria(CarModelInfo.class, c); > Collection modelInfos = = broker.getCollectionByQuery(q2); > > /* Total results from Q1 */ > BigDecimal totalParts = new BigDecimal("0"); > for (Iterator it = parts.iterator(); iter.hasNext();) { > CarAddedPart part = (CarAddedPart) it.next(); > totalParts = totalParts.add(part.getWeight); > } > > /* Total results from Q2 */ > BigDecimal totalModels = new BigDecimal("0"); > for (Iterator it = modelInfos.iterator(); iter.hasNext();) { > CarInfoModel model = (CarInfoModel) it.next(); > totalModels = totalModels.add(model.getWeight); > } > > BigDecimal totalWeight = totalParts.add(totalModels); > > Any remaining errors can > > Using a running total inside the code instead of inside the database is a > habit from my particular problem domain (where we often have to do currency > conversions, so we can't do SUM() in the database). Ron's will be far > quicker. > > I'm going home now (Ah, the London Underground, Rush Hour, High Temperatures > and High Humidity. Gotta love it.) > > Cheers, > Charles. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]