You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wicketshafi <sm...@gmail.com> on 2007/12/03 09:10:47 UTC

pagination in Wicket...


I'm  using pagination , i want to get records from the next page... 
how do I query the start and count in mysql....
can any one help me ...

regards
Shafi
  
-- 
View this message in context: http://www.nabble.com/pagination-in-Wicket...-tf4934874.html#a14125319
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: pagination in Wicket...

Posted by Igor Vaynberg <ig...@gmail.com>.
urgh, this is not a mysql mailing list. while you guys are just trying
to help, if this becomes a pattern there will be way too much noise on
this already pretty freakin busy list. so please next time please tell
the person to go to the appropriate forum, or in this case simply type
in "mysql paginataion" into google and press the "im feeling lucky"
button...

-igor


On Dec 3, 2007 2:42 AM, Roy van Rijn <ro...@gmail.com> wrote:
> This also works pretty well using Hibernate:
>
> Criteria c = session.createCriteria(...);
> c.setFirstResult(start);
> c.setMaxResults(length);
>
> But beware with using this. Hibernate has Java-Filters for some cases.
> ResultTransformers can't be used in combination with paging. The query
> will select the amount you need but the transformers could remove
> results from that list.
>
> We've noticed that if you automaticly join tables using the HBM file
> (fetch) then Hibernate will remove results too. This is very annoying.
>
> For example:
> Table 1:
> key - t2key - value
> 1 1 First entry
> 2 1 Second entry
> 3 2 Blabla
> 4 3 More bla..
>
> Table 2:
> key - value
> 1 Some value
> 2 Some other value
> 3 Some third value
>
> If you fetch-join table 1 when you query table 2 and try to collect
> the first 3 results hibernate will generate the following SQL:
>
> select * from table2  t2 left join table1 t1 on t2.t2key = t2.key limit 0,2;
>
> What will be retrieved:
> 1 Some value 1 1 First entry
> 1 Some value 2 1 Second entry
> 2 Some other value 3 2 Blabla
>
> Because the first (queried) table has duplicate entries Hibernate will
> create the following objects:
>
> table1 object: "1, Some value"
> with List<table2 object> {"1,1,First entry", "2,1,Second entry"}
>
> and
>
> table1 object: "2, Some other value"
> with List<table2 object> {"3,2,Bla bla"}
>
> Just two results... paging messed up :(
>
> This is my experience with paging and ORM mappers, you have to be very
> carefull hehe. If somebody here knows a solution to this problem,
> please let me know!
>
> Roy
>
>
>
> On 12/3/07, Uwe Schäfer <sc...@thomas-daily.de> wrote:
> > wicketshafi schrieb:
> >
> > > how do I query the start and count in mysql....
> >
> >  The LIMIT clause can be used to constrain the number of rows returned
> > by the SELECT  statement. LIMIT takes one or two numeric arguments,
> > which must both be non-negative integer constants (except when using
> > prepared statements).
> >
> > With two arguments, the first argument specifies the offset of the first
> > row to return, and the second specifies the maximum number of rows to
> > return. The offset of the initial row is 0 (not 1):
> >
> > SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
> >
> > see http://dev.mysql.com/doc/refman/5.0/en/select.html
> >
> > --
> >
> > THOMAS DAILY GmbH
> > Adlerstraße 19
> > 79098 Freiburg
> > Deutschland
> > T  + 49 761 3 85 59 0
> > F  + 49 761 3 85 59 550
> > E  schaefer@thomas-daily.de
> > www.thomas-daily.de
> >
> > Geschäftsführer/Managing Directors:
> > Wendy Thomas, Susanne Larbig
> > Handelsregister Freiburg i.Br., HRB 3947
> >
> > Registrieren Sie sich unter http://morningnews.thomas-daily.de für die
> > kostenfreien TD Morning News, eine Auswahl aktueller Themen des Tages
> > morgens um 9:00 in Ihrer Mailbox.
> >
> > Hinweis: Der Redaktionsschluss für unsere TD Morning News ist täglich um
> > 8:30 Uhr. Es werden vorrangig Informationen berücksichtigt, die nach
> > 16:00 Uhr des Vortages eingegangen sind. Die Email-Adresse unserer
> > Redaktion lautet redaktion@thomas-daily.de.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: pagination in Wicket...

Posted by Roy van Rijn <ro...@gmail.com>.
This also works pretty well using Hibernate:

Criteria c = session.createCriteria(...);
c.setFirstResult(start);
c.setMaxResults(length);

But beware with using this. Hibernate has Java-Filters for some cases.
ResultTransformers can't be used in combination with paging. The query
will select the amount you need but the transformers could remove
results from that list.

We've noticed that if you automaticly join tables using the HBM file
(fetch) then Hibernate will remove results too. This is very annoying.

For example:
Table 1:
key - t2key - value
1 1 First entry
2 1 Second entry
3 2 Blabla
4 3 More bla..

Table 2:
key - value
1 Some value
2 Some other value
3 Some third value

If you fetch-join table 1 when you query table 2 and try to collect
the first 3 results hibernate will generate the following SQL:

select * from table2  t2 left join table1 t1 on t2.t2key = t2.key limit 0,2;

What will be retrieved:
1 Some value 1 1 First entry
1 Some value 2 1 Second entry
2 Some other value 3 2 Blabla

Because the first (queried) table has duplicate entries Hibernate will
create the following objects:

table1 object: "1, Some value"
with List<table2 object> {"1,1,First entry", "2,1,Second entry"}

and

table1 object: "2, Some other value"
with List<table2 object> {"3,2,Bla bla"}

Just two results... paging messed up :(

This is my experience with paging and ORM mappers, you have to be very
carefull hehe. If somebody here knows a solution to this problem,
please let me know!

Roy


On 12/3/07, Uwe Schäfer <sc...@thomas-daily.de> wrote:
> wicketshafi schrieb:
>
> > how do I query the start and count in mysql....
>
>  The LIMIT clause can be used to constrain the number of rows returned
> by the SELECT  statement. LIMIT takes one or two numeric arguments,
> which must both be non-negative integer constants (except when using
> prepared statements).
>
> With two arguments, the first argument specifies the offset of the first
> row to return, and the second specifies the maximum number of rows to
> return. The offset of the initial row is 0 (not 1):
>
> SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
>
> see http://dev.mysql.com/doc/refman/5.0/en/select.html
>
> --
>
> THOMAS DAILY GmbH
> Adlerstraße 19
> 79098 Freiburg
> Deutschland
> T  + 49 761 3 85 59 0
> F  + 49 761 3 85 59 550
> E  schaefer@thomas-daily.de
> www.thomas-daily.de
>
> Geschäftsführer/Managing Directors:
> Wendy Thomas, Susanne Larbig
> Handelsregister Freiburg i.Br., HRB 3947
>
> Registrieren Sie sich unter http://morningnews.thomas-daily.de für die
> kostenfreien TD Morning News, eine Auswahl aktueller Themen des Tages
> morgens um 9:00 in Ihrer Mailbox.
>
> Hinweis: Der Redaktionsschluss für unsere TD Morning News ist täglich um
> 8:30 Uhr. Es werden vorrangig Informationen berücksichtigt, die nach
> 16:00 Uhr des Vortages eingegangen sind. Die Email-Adresse unserer
> Redaktion lautet redaktion@thomas-daily.de.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: pagination in Wicket...

Posted by Uwe Schäfer <sc...@thomas-daily.de>.
wicketshafi schrieb:

> how do I query the start and count in mysql....

  The LIMIT clause can be used to constrain the number of rows returned 
by the SELECT  statement. LIMIT takes one or two numeric arguments, 
which must both be non-negative integer constants (except when using 
prepared statements).

With two arguments, the first argument specifies the offset of the first 
row to return, and the second specifies the maximum number of rows to 
return. The offset of the initial row is 0 (not 1):

SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15

see http://dev.mysql.com/doc/refman/5.0/en/select.html

-- 

THOMAS DAILY GmbH
Adlerstraße 19
79098 Freiburg
Deutschland
T  + 49 761 3 85 59 0
F  + 49 761 3 85 59 550
E  schaefer@thomas-daily.de
www.thomas-daily.de

Geschäftsführer/Managing Directors:
Wendy Thomas, Susanne Larbig
Handelsregister Freiburg i.Br., HRB 3947

Registrieren Sie sich unter http://morningnews.thomas-daily.de für die 
kostenfreien TD Morning News, eine Auswahl aktueller Themen des Tages 
morgens um 9:00 in Ihrer Mailbox.

Hinweis: Der Redaktionsschluss für unsere TD Morning News ist täglich um 
8:30 Uhr. Es werden vorrangig Informationen berücksichtigt, die nach 
16:00 Uhr des Vortages eingegangen sind. Die Email-Adresse unserer 
Redaktion lautet redaktion@thomas-daily.de.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org