Thanks Wally, really good... The final code: ****** Criteria crit = new Criteria(); org.apache.ojb.broker.query.ReportQueryByCriteria query = new ReportQueryByCriteria(Estudiant.class, crit); query.setColumns(new String[] { "MAX(ID)" }); Iterator iter2 = broker.getReportQueryIteratorByQuery(query); if (iter2.hasNext()){ Object[] objs = (Object[]) iter2.next(); Integer max = (Integer) objs[0]; System.out.println("MAX:"+max); } ****** But I have another question... it's the best way to generate and ID for store new items??? Sequence is the best?? Thanks. Carles
-----Mensaje original----- De: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Enviado el: mié 14/04/2004 15:40 Para: OJB Users List CC: Asunto: RE: Select MAX Hi Carles, Report Queries return an Iterator of Object[] Object[] objs = iter2.next(); Integer max = objs[0]; Hope this helps, Wally -----Original Message----- From: Carles Duque [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 7:54 AM To: [EMAIL PROTECTED] Subject: Select MAX I have a problem with this type of select. This is my code: ************** Criteria crit =3D new Criteria(); org.apache.ojb.broker.query.ReportQueryByCriteria query =3D new = ReportQueryByCriteria(Estudiant.class, crit); query.setColumns(new String[] { "MAX(ID)" }); Iterator iter2 =3D broker.getReportQueryIteratorByQuery(query); *********** But I don't know how return this iter2.next(). An Object of nothing... = because It generate ClassCastException with Estudiant, Long, Integer and = Double. Anyone Can help me? Thanks!! Carles Duque --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]