You're right, there is no guarantee from the spec that other app servers
will return data in order or even allow you to specify the ORDER BY
clause in the finder sql.  For that matter, there is no guarantee that
the database has a sql interface.

It gets even worse.  The current spec for EJB-QL has no support for
ordering.  The *only* way to write a 100% spec-compliant app which does
ordering is to implement the sorting yourself, in application code, in
Java.

It's pretty obvious to me at least that the people developing the EJB
specification have never actually used their ideas to develop a real
world application.  Fortunately for us, container vendors are less
insulated from the eventual customers; it's a pretty safe bet that most
servers will let you configure the ordering in the database query
somehow.  I wouldn't worry about it, but no, it's not standard.

Jeff Schnitzer

> -----Original Message-----
> From: Eddie Post [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 15, 2001 3:48 PM
> To: Orion-Interest
> Subject: Re: Collection or list as return ??
> 
> 
> Thanks Scott,
> 
> Thanks for the test (stupid that I didn't thought about that 
> ;) ). So, yes 
> the returned Collection (read: ArrayList) is a sorted one.
> But how general is this, as I can't find anything in the J2EE 
> spec about 
> this and is it possible that Orion will change this such that 
> it isn't 
> sorted anymore ?
> 
> 
> What do you think ? Let the DB do the "order by" or just let 
> the sort method 
> of Collections do the trick ? I have noticed that the sort 
> method is very 
> fast.
> 
> 
> Eddie
> 
> 
> 
> >From: Scot Weber <[EMAIL PROTECTED]>
> >Reply-To: Orion-Interest <[EMAIL PROTECTED]>
> >To: Orion-Interest <[EMAIL PROTECTED]>
> >Subject: Re: Collection or list as return ??
> >Date: Fri, 15 Jun 2001 12:15:46 -0700
> >
> >Eddie,
> >
> >   I just tested it . . .
> >
> >MyTestHome.java __________
> >
> >   public interface MyTestHome {
> >
> >     ....
> >     public Collection findAll () ...
> >
> >   }
> >
> >mytest.jsp__________
> >
> >   ....
> >
> >   <%= myTestHome.findall ().getClass () %>
> >
> >output_____________
> >
> >   java.util.ArrayList
> >
> >peace - scot
> >
> > > Eddie wrote:
> > >
> > > Hellu there,
> > >
> > > Some time ago someone made a remark that it make no sense 
> putting a
> > > "ORDER
> > > BY" in the where clause in the orion-ejb-jar.xml, as the finder
> > > methods of
> > > the home interface do return a Collection, which are not sorted by
> > > definition.
> > >
> > > Hmmm makes sence, but if I play around with it and put a 
> "ORDER BY id
> > > ASC"
> > > or "ORDER BY id DESC" in the where clause in the 
> orion-ejb-jar.xml, to
> > > fine
> > > tune some queries, it does  return sorted collections !!!!
> > >
> > > Howcome ?? Does the finder methods return a  sorted List as a J2EE
> > > feature,
> > > that is a subClass of a Collection, or is this just Orion. ??
> > >
> > > The thing is that I like to optimize my queries, but if 
> this feature
> > > isn't
> > > J2EE for example I will have a problem with the following 
> upgrades if
> > > it's
> > > left out for some reason !!
> > >
> > > BTW: in the J2EE spec, in section 10.5.6 they only talk about the
> > > Collection
> > > data type.!!
> > >
> > > Some advise please ??
> > > Eddie
> >
> >--
> >
> >   scot weber - [EMAIL PROTECTED]
> >   -------------
> >   Given a choice between a folly and a sacrament, one should
> >   always choose the folly -- because we know a sacrament
> >   will not bring us closer to God and there's always a chance
> >   that a folly will. - Erasmus
> >
> >   The only man who never makes a mistake is the man who
> >   never does anything. - Theodore Roosevelt.
> >
> 
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at 
http://www.hotmail.com.



Reply via email to