RE: [OJB-developers] Multiple fields for Criteria.orderBy()?
Brought to you by:
thma
From: John F. <jfr...@so...> - 2002-04-22 14:05:12
|
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()? >=20 >=20 > hi again john, >=20 > i had a look at multiple orderBy. it's easy to do. the main=20 > problem is how > to define ASC and DESC ? > do we separate ASC/DESC or do we include it in the fieldNames ? >=20 > - orderBy(String[] fieldNames, boolean[] order); > ie: orderBy(new String[]{"name", "salary"}, new boolean[]=20 > {true,false}); > this is simple but not readable. >=20 > include ASC / DESC in the fieldNames array: >=20 >=20 > - orderBy(String[] fieldNamesOrder); > ie: orderBy(new String[]{"name ASC", "salary DESC"}); > this is readable but needs parsing. >=20 > there's a third approach: >=20 > - addOrderBy(String fieldName, boolean isAscending) > ie: addOrderBy("name",true); > addOrderBy("salary", false); >=20 > this is the solution i prefer. it could also be used for groupBy. >=20 > any comments ??? >=20 > greetings jakob >=20 >=20 > ----- 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()? >=20 >=20 > > hi john, > > > > i just returned from my 2 weeks holidays. > > i've implemented 'groupBy' with an array of fields, so it=20 > 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=20 > 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=20 > 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 > > >=20 |