Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 8203 invoked from network); 6 Jun 2010 08:17:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Jun 2010 08:17:20 -0000 Received: (qmail 37477 invoked by uid 500); 6 Jun 2010 08:17:20 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 37263 invoked by uid 500); 6 Jun 2010 08:17:18 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 37254 invoked by uid 99); 6 Jun 2010 08:17:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jun 2010 08:17:17 +0000 X-ASF-Spam-Status: No, hits=-1500.9 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jun 2010 08:17:16 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o568GtQK027517 for ; Sun, 6 Jun 2010 08:16:56 GMT Message-ID: <29991020.204301275812215713.JavaMail.jira@thor> Date: Sun, 6 Jun 2010 04:16:55 -0400 (EDT) From: "Waruna Ranasinghe (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-1684) Prepared query cache won't work if the start index (i.e setFirstResult) is changed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Prepared query cache won't work if the start index (i.e setFirstResult) is changed ---------------------------------------------------------------------------------- Key: OPENJPA-1684 URL: https://issues.apache.org/jira/browse/OPENJPA-1684 Project: OpenJPA Issue Type: Bug Components: query Affects Versions: 2.0.0 Environment: Ubuntu 9.04, Sun jdk6, database: H2 Reporter: Waruna Ranasinghe I have implemented pagination so that only 6 entries are fetched for a page. First, I get the first 6 entries (First page: from 0 to 6) by setting ; query = query.setFirstResult(startIndex); //startindex = 0 query = query.setMaxResults(pageSize); //pageSize = 6 Then the db query is sent as follow: SELECT t0.id FROM ....... LIMIT ? And the above sql is cached against its JPQL When I try to get the next page (Second page: from 6 to 12) by setting; query = query.setFirstResult(startIndex); //startindex = 6 query = query.setMaxResults(pageSize); //pageSize = 6 Then the db query is still sent as follow: SELECT t0.id FROM ....... LIMIT ? Where as it should be SELECT t0.id FROM ....... LIMIT ? OFFSET ? This problem occurs because it takes the SQL query from the cache against the JPQL (JPQL is same as the first) which returns the old SQL query in which there was no any OFFSET keyword set. This can be fixed by setting the OFFSET value (in H2) to zero even if it is the default value OR setting the relevant keyword (OFFSET in H2, LIMIT in MySQL) to default, so that it can be taken from the cache and the changed offset values will be set without a problem. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.