RE: Limit the result of a query.

From: Alex Gunawan Wibowo (netzone_tec..ahoo.com)
Date: Wed Dec 01 2004 - 08:42:42 EST

  • Next message: Alex Gunawan Wibowo: "RE: Limit the result of a query."

    Thinking about it again, it is quite possible...

    public List myQuery (String startID, int size){
        DataContext ctxt=
    BasicServletConfiguration.getDefaultContext(request.getSession());

        Expression qual =
    ExpressionFactory.greaterExp("startID", new
    Integer(startID));
        SelectQuery q = new SelectQuery(Artist.class,
    qual);
        q.setFetchSize(size);
        Ordering ord = new Ordering ( Ordering.ASC);
        q.addOrdering(ord);

        List result = ctxt.performQuery(q);

        return result;
    }

    Is this good? (I haven't try it yet.. i will do it
    tomorrow).
    Am I doing something wrong? is there any better way?
    I can't use QueryIterator here... i think...

    Best regards,

    Alex.
     
    --- Alex Gunawan Wibowo <netzone_tec..ahoo.com>
    wrote:

    > Hmmm.... that is quite interesting...
    > But really what i want is the ability to do this
    > schema...
    >
    > The database contains 1000 of records. The first
    > time
    > user view a page, only 50 records are fetched &
    > displayed.
    > User will then click a link, presumeably the link
    > has a parameter (2,50) <- fetch the 2nd 50
    > records.
    > The page displays record 51-101
    > etc.
    > I'm looking for a method that does that.. (or
    > any other way to do it in Cayenne)..
    > setPageSize is not really what i want, although it
    > seems very good.
    > setFetchSize() seems good as well, but in my case
    > it will only satisfy the first time the user request
    > (i.e record 1-50). I can't think of a way to do
    > what I want with setFetchSize()...
    >
    >
    > Any idea??
    >
    >
    > Thanks a lot!
    >
    > --- Gary Jarrel <garyjarre..rownbilljarrel.com.au>
    > wrote:
    >
    > > Yeah you can use setPageSize(int) for a particular
    > > query. Similar to:
    > >
    > >
    >
    http://www.objectstyle.org/cayenne/userguide/fetch/other.html
    > >
    > > - Gary
    > >
    > > -----Original Message-----
    > > From: Alex Gunawan Wibowo
    > > [mailto:netzone_tec..ahoo.com]
    > > Sent: Wednesday, December 01, 2004 3:50 PM
    > > To: Cayenne
    > > Subject: Limit the result of a query.
    > >
    > > Hello,
    > >
    > >
    > > Is it possible in Cayenne to select the first X
    > > entry
    > > of
    > > a query? I.e. something like what Google have..
    > > first, display the first 10 matching, then if user
    > > still
    > > want more, fetch item 11-20, etc etc etc.
    > >
    > > Is it possible? Or do I have to do it manually in
    > > Java?
    > >
    > > Thx a lot!
    > >
    > > Best regards,
    > >
    > > Alex.
    > >
    > > =====
    > > Alex Wibowo
    > > ~ Second is a failure ~
    > > The University of Melbourne
    > > Department of Computer Science and Software
    > > Engineering
    > > Website - http://www.cs.mu.oz.au/~agwibowo
    > > Team Wasabi -
    > > http://www.cs.mu.oz.au/SE-projects/s440gh
    > > ==============================================
    > >
    > > __________________________________________________
    > > Do You Yahoo!?
    > > Tired of spam? Yahoo! Mail has the best spam
    > > protection around
    > > http://mail.yahoo.com
    > >
    > > --
    > > No virus found in this incoming message.
    > > Checked by AVG Anti-Virus.
    > > Version: 7.0.289 / Virus Database: 265.4.4 -
    > Release
    > > Date: 30/11/2004
    > >
    > >
    > >
    >
    >
    > =====
    > Alex Wibowo
    > ~ Second is a failure ~
    > The University of Melbourne
    > Department of Computer Science and Software
    > Engineering
    > Website - http://www.cs.mu.oz.au/~agwibowo
    > Team Wasabi -
    > http://www.cs.mu.oz.au/SE-projects/s440gh
    > ==============================================
    >
    >
    >
    > __________________________________
    > Do you Yahoo!?
    > The all-new My Yahoo! - Get yours free!
    > http://my.yahoo.com
    >
    >
    >

                    
    __________________________________
    Do you Yahoo!?
    All your favorites on one personal page – Try My Yahoo!
    http://my.yahoo.com



    This archive was generated by hypermail 2.0.0 : Wed Dec 01 2004 - 08:42:49 EST