You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Jose Maria Lopez Lagunas <ch...@visual-limes.com> on 2002/12/03 14:43:04 UTC
More than one field in orderby
Hi.
I've noticed that the "orderby" attribute of "collection-descriptor"
only allows one field. I have a collection that I would want to order by
two fields. I put two fields that way: orderby="ORDEN,GTERA" but it
didn't work. I don't know if that is going to be implemented in the
future. Meanwhile I'll modify the PersistenceBrokerImpl to allow several
fields separated by commas.
This is what I've done:
class org.apache.ojb.broker.singlevm.PersistenceBrokerImpl
...
private void retrieveCollection(Object obj, ClassDescriptor cld,
CollectionDescriptor cds)
{
if (cds.getCascadeRetrieve())
{
...
// check if collection must be ordered
if (cds.getOrderBy() != null)
{
// My modifications ///////////////////////////
String aux;
java.util.StringTokenizer tok = new
StringTokenizer(cds.getOrderBy(),",");
while (tok.hasMoreTokens()) {
aux = tok.nextToken().trim();
fkQuery.getCriteria().addOrderBy(aux,cds.isAscending());
}
/////////////////////////////////////////////////////
// fkQuery.getCriteria().addOrderBy(cds.getOrderBy(),
cds.isAscending());
}
...
}
Thank you in advance.
Jose Maria
Re: More than one field in orderby
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi jose,
i'd like to have a clean solution providing multiple order by and their
_individual ASC/DESC_ in the repository.xml. being not an xml-expert i do
not know how to define this properly. also i do not know how to avoid
breaking everyone's repository by adding multi order by ????
jakob
----- Original Message -----
From: "Jose Maria Lopez Lagunas" <ch...@visual-limes.com>
To: <oj...@jakarta.apache.org>
Sent: Tuesday, December 03, 2002 2:43 PM
Subject: More than one field in orderby
> Hi.
>
> I've noticed that the "orderby" attribute of "collection-descriptor"
> only allows one field. I have a collection that I would want to order by
> two fields. I put two fields that way: orderby="ORDEN,GTERA" but it
> didn't work. I don't know if that is going to be implemented in the
> future. Meanwhile I'll modify the PersistenceBrokerImpl to allow several
> fields separated by commas.
>
> This is what I've done:
> class org.apache.ojb.broker.singlevm.PersistenceBrokerImpl
> ...
> private void retrieveCollection(Object obj, ClassDescriptor cld,
> CollectionDescriptor cds)
> {
> if (cds.getCascadeRetrieve())
> {
>
> ...
>
> // check if collection must be ordered
> if (cds.getOrderBy() != null)
> {
> // My modifications ///////////////////////////
> String aux;
> java.util.StringTokenizer tok = new
> StringTokenizer(cds.getOrderBy(),",");
> while (tok.hasMoreTokens()) {
> aux = tok.nextToken().trim();
>
fkQuery.getCriteria().addOrderBy(aux,cds.isAscending());
> }
> /////////////////////////////////////////////////////
>
> // fkQuery.getCriteria().addOrderBy(cds.getOrderBy(),
> cds.isAscending());
> }
> ...
>
> }
>
>
>
> Thank you in advance.
>
> Jose Maria
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>