Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] MySQL LIMIT Clause in EclipseLink

Please log this bug in bugzilla.

A workaround may be to access the DatabaseQuery from the JPA Query and set
it to be unprepared.

((JpaQuery)query).getDatabaseQuery().setIsPrepared(false);


JackOfHearts199 wrote:
> 
> Hi all,
> i have a large table that needs paging. I'm using EclipseLink.
> With EL 1.0.2 i noticed that pagination is done by filtering the entire
> result and not directly with LIMIT clause.
> I've tried EL Milestone 1.1.3 M3 and now in my generated sql string i have
> LIMIT. 
> The performaces are good but now i have a problem.
> If i use 0 in setFirstResult method i get the first page, but when i try
> to view the next page using setFirstResult again, the generated sql
> contains only one parameter.
> 
> For example:
> 
> setFirstResult(0)
> setMaxResults(50)
> produces "LIMIT 50" at the end of the sql query
> 
> after doing this, i want to change page:
> setFirstResult(50)
> this produces "LIMIT 50" instead of "LIMIT 50, 50" and my page doesn't
> change.
> 
> One more thing to say.
> If i pass to the first call of setFirstResult a different value than 0
> (for example 1) then it works well.
> I can change page and the generated sql has the correct LIMIT clause with
> two parameters.
> 
> Maybe its a bug?
> Very thanks, Eros.
> 
> 
> EDIT:
> Actually i've solved by changing in file
> /source/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/MySQLPlatform.java
> 
> at line 574 from
>      if (firstRow > 0) {
> to
>      if (firstRow >= 0) {
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/MySQL-LIMIT-Clause-in-EclipseLink-tp20698131p20720095.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top