The problem is that How can we just define one method such as

        <finder-method query="ORDER BY $surname $1">
                <!-- Generated SQL: "select Employee ...." -->
                <method>
                        <ejb-name>Employee</ejb-name>
                        <method-name>findAll</method-name>
                        <method-params>
                        </method-params>
                </method>
        </finder-method>

And depend on $1 parameter (ASC or DESC) was transfered.  we return the
result with alphabetical
order or vice versa. Is it possible? Any solutions?


-----Original Message-----
From: Robert Hargreaves [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 10:46 AM
To: Orion-Interest
Subject: RE: findByXXX() with an ORDER BY parameter for
Container-managed bean ?


I have to disagree. We've been using ORDER BY statements in finder method
queries since day 1 and they work fine.
As an example we have a findAll for an Employee entity bean configured as:

        <finder-method query="ORDER BY $surname ASC">
                <!-- Generated SQL: "select Employee ...." -->
                <method>
                        <ejb-name>Employee</ejb-name>
                        <method-name>findAll</method-name>
                        <method-params>
                        </method-params>
                </method>
        </finder-method>

and when we run the following we get a list of surnames in alphabetical
order.

        EmployeeHome empHome = (EmployeeHome)initCtx.lookup("Employee");
      ArrayList al = (ArrayList)empHome.findAll();
      Iterator iter = al.iterator();
       
      while(iter.hasNext()){
        Employee emp = (Employee)iter.next();
            System.out.println(emp.getSurname());
      }

If we take the "ORDER BY $surname ASC" statement out, the list ain't in
alphabetical order.

Hope this helps.

Robert Hargreaves.

> -----Original Message-----
> From: Markus Holmberg [mailto:[EMAIL PROTECTED]]
> Sent: 30 March 2001 16:47
> To: Orion-Interest
> Cc: Magnus Rydin (E-mail)
> Subject: Re: findByXXX() with an ORDER BY parameter for
> Container-managed bean ?
> 
> 
> Having ORDER BY in finder method queries is futile. Iterators of
> java.util.Collection are not required to return objects in any kind of
> order.
> 

Reply via email to