Re: [OJB-developers] Multiple fields for Criteria.orderBy()?
Brought to you by:
thma
From: Jakob B. <jbr...@ho...> - 2002-04-22 20:50:01
|
hi, i implemented new methods addGroupBy(String fieldName) and addOrderBy(String fieldName, boolean sortAscending) for class Criteria to support multiple field in order by: crit = new Criteria(); ... crit.addOrderBy("name"); // ascending crit.addOrderBy("id", false); // descending the old methods orderBy(String fieldName, boolean sortAscending) and orderBy(String fieldName) still exist for compatibility. the same pattern is also implemented for groupBy. greetings jakob ----- Original Message ----- From: "John Freeborg" <jfr...@so...> To: "Jakob Braeuchi" <jbr...@ho...>; "ojb" <obj...@li...> Sent: Monday, April 22, 2002 4:05 PM Subject: RE: [OJB-developers] Multiple fields for Criteria.orderBy()? The third approach would be my favorite. If you need multiple fields for sorting, you just call the method again as you illustrated. - John > -----Original Message----- > From: Jakob Braeuchi [mailto:jbr...@ho...] > Sent: Monday, April 22, 2002 4:05 AM > To: John Freeborg; ojb > Subject: Re: [OJB-developers] Multiple fields for Criteria.orderBy()? > > > hi again john, > > i had a look at multiple orderBy. it's easy to do. the main > problem is how > to define ASC and DESC ? > do we separate ASC/DESC or do we include it in the fieldNames ? > > - orderBy(String[] fieldNames, boolean[] order); > ie: orderBy(new String[]{"name", "salary"}, new boolean[] > {true,false}); > this is simple but not readable. > > include ASC / DESC in the fieldNames array: > > > - orderBy(String[] fieldNamesOrder); > ie: orderBy(new String[]{"name ASC", "salary DESC"}); > this is readable but needs parsing. > > there's a third approach: > > - addOrderBy(String fieldName, boolean isAscending) > ie: addOrderBy("name",true); > addOrderBy("salary", false); > > this is the solution i prefer. it could also be used for groupBy. > > any comments ??? > > greetings jakob > > > ----- Original Message ----- > From: "Jakob Braeuchi" <jbr...@ho...> > To: "John Freeborg" <jfr...@so...>; "ojb" > <obj...@li...> > Sent: Saturday, April 20, 2002 6:16 PM > Subject: Re: [OJB-developers] Multiple fields for Criteria.orderBy()? > > > > hi john, > > > > i just returned from my 2 weeks holidays. > > i've implemented 'groupBy' with an array of fields, so it > will be easy for > > me to do so for 'orderBy' also. > > > > greetings jakob > > > > ----- Original Message ----- > > From: "John Freeborg" <jfr...@so...> > > To: "ojb" <obj...@li...> > > Sent: Tuesday, April 16, 2002 8:45 PM > > Subject: [OJB-developers] Multiple fields for Criteria.orderBy()? > > > > > > I just ran across wanting to perform a query where I have multiple > > fields listed for sorting, e.g.: > > > > SELECT areaCode, exchange, number, state, cost FROM > phoneNumbers ORDER > > BY areaCode, exchange > > > > However, OJB 0.8.375 at the PersistenceBroker layer doesn't seem to > > allow this as Criteria.orderBy() and SqlGenerator.getOrderByClause() > > clearly want to deal with just a single field name. > > > > Anyone already working on this functionality? > > > > I was thinking of simplying adding an array like capability > just like > > the Criteria.groupBy() which would adapt well to existing code. > > > > Regards, > > - John Freeborg > > > > _______________________________________________ > > Objectbridge-developers mailing list > > Obj...@li... > > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > _______________________________________________ > > Objectbridge-developers mailing list > > Obj...@li... > > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > _______________________________________________ Objectbridge-developers mailing list Obj...@li... https://lists.sourceforge.net/lists/listinfo/objectbridge-developers |