db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bogdan Vatkov" <bvat...@globaltech-bg.com>
Subject Re: Further question [Newbie] Getting limited number of rows
Date Tue, 09 Mar 2004 15:29:47 GMT
Hi,
I am not sure but i think this customization might be usefull when selecting
a large amount of rows
in cases where you are not going to extract well specified torque DataObject
but a Select statement
created on the fly ...for example JOIN of 2-3-4 different tables ...then you
do not have torque object to represent the selected columns ..hope this
gives some answers ..

Regards,
Bogdan
----- Original Message -----
From: "bhiyavudh" <bhiyavudh@hotmail.com>
To: "Apache Torque Users List" <torque-user@db.apache.org>
Sent: Tuesday, March 09, 2004 5:10 PM
Subject: Further question [Newbie] Getting limited number of rows


> Hi all,
>     A further question on LargeSelect. I have try your sample with my data
> and it work ok, just check on the API doc and it mentions that you can
> customize "addSelectColumns() , populateObjects(), row2Object() and
> populateObject() methods from an existing Peer class". I am not sure why
> would we need to customize these methods because with the default
> implementation it already copy data from the list of village records to
list
> of object we need (the one we passed to LargeSelect constructor as
> returnBuilderClassName).Any specific reason for customization. Is it
> intended for your own implementation of the business object, not the one
> generated by torque. Sorry I am not quite sure what exactly does it mean.
> Regards,
>
> ----- Original Message -----
> From: "Bogdan Vatkov" <bvatkov@globaltech-bg.com>
> To: "Apache Torque Users List" <torque-user@db.apache.org>
> Sent: Tuesday, March 09, 2004 11:11 AM
> Subject: Re: [Newbie] Getting limited number of rows
>
>
> > Hi Joacim,
> >
> > I think the best way to do the thing you are trying to do is to use
> > LargeSelect
> > it provides more functionality than just number of rows limitation.
> > It gives you the paged tables that almost every weblication needs.
> > Actually using LargeSelect you are not responsible for the SQL statement
> > /( Criteria preparation) for limiting the rows anymore.
> > I am using it and it is quite good ..in fact it has all that I need.
> >
> > 1) display single page of a db table (example 10 rows)
> > 2) display the navigation info (example "page 3 of 10 total")
> > 3) and of course methods for first/prev/next/last pages
> > 4) the LargeSelect class provides customization of the number of rows to
> be
> > fetched..and numbers of rows to be displayed in a single page
> >
> >
> > example from my code: (there is some of my local logic ..like
weblication
> > action object ..but i think you will get the idea of using the
LargeSelect
> > object)
> >
> > load the data:
> >
> >   private static final int PAGE_SIZE = 10; // maximum page size
> >   private static final int PAGES_FETCH_COUNT = 10; // pages to be loaded
> on
> > time
> >
> >   private void LoadLargeSelect(Criteria parameter) {
> >     largeSelect = new LargeSelect(parameter, PAGE_SIZE,
PAGES_FETCH_COUNT,
> >                                   CsVpbxPeer.class.getName());
> >     try {
> >       largeSelect.getNextResults();
> >     }
> >     catch (Exception e) {
> >       logError(e);
> >     }
> >   }
> >
> >
> > weblication actions interpret:
> >
> >
> >           if (action.equals(Action.COMMON_LIST_FIRST_PAGE)) {
> >             businessObjectList = largeSelect.getPage(1);
> >           }
> >           else if (action.equals(Action.COMMON_LIST_LAST_PAGE)) {
> >             businessObjectList =
> > largeSelect.getPage(largeSelect.getTotalPages());
> >           }
> >           else if (action.equals(Action.COMMON_LIST_NEXT_PAGE)) {
> >             businessObjectList = largeSelect.getNextResults();
> >           }
> >           else if (action.equals(Action.COMMON_LIST_PREV_PAGE)) {
> >             businessObjectList = largeSelect.getPreviousResults();
> >           }
> >           else {
> >             largeSelect.invalidateResult();
> >             businessObjectList = largeSelect.getPage(1);
> >           }
> >
> > I am not sure that it is what you need but is a good start point.
> >
> > With best regards,
> > Bogdan Vatkov
> >
> > ----- Original Message -----
> > From: "Joacim Turesson" <joacim.turesson@profuture.se>
> > To: <torque-user@db.apache.org>
> > Sent: Tuesday, March 09, 2004 11:35 AM
> > Subject: [Newbie] Getting limited number of rows
> >
> >
> > > Hi!
> > >
> > >
> > >
> > > I'm using Torque and it works fine:-)
> > >
> > >
> > >
> > > I'm working with a webbapplication and I want to display a limited
> > > amount of a data in a list.
> > >
> > >
> > >
> > > How do I get a limited number of rows, and still knows how many total
> > > number of rows there exist?
> > >
> > >
> > >
> > > As I understand:
> > >
> > > * setOffset indicates from where I start (zero based)
> > > * setLimit indicates how many rows from the offset I get
> > >
> > >
> > >
> > > Do I have to do a select count statement with the criteria above
without
> > > offset and limit to get the total number of rows?
> > >
> > > Or is it a better way?
> > >
> > >
> > >
> > > Best Regards
> > >
> > >
> > >
> > > Joacim Turesson
> > >
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message