Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 65080 invoked from network); 7 Apr 2010 16:28:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Apr 2010 16:28:57 -0000 Received: (qmail 91215 invoked by uid 500); 7 Apr 2010 16:28:57 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 91188 invoked by uid 500); 7 Apr 2010 16:28:57 -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 91180 invoked by uid 99); 7 Apr 2010 16:28:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 16:28:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FRT_STOCK2 X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 16:28:54 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9ADFE234C4AC for ; Wed, 7 Apr 2010 16:28:33 +0000 (UTC) Message-ID: <526207474.46391270657713633.JavaMail.jira@brutus.apache.org> Date: Wed, 7 Apr 2010 16:28:33 +0000 (UTC) From: "Donald Woods (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Resolved: (OPENJPA-1602) Query with lock mode set to PESSIMISTIC_WRITE does not have for update clause attached to the sql when runs twice In-Reply-To: <209652193.555711269885927340.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Donald Woods resolved OPENJPA-1602. ----------------------------------- Resolution: Fixed > Query with lock mode set to PESSIMISTIC_WRITE does not have for update clause attached to the sql when runs twice > ----------------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-1602 > URL: https://issues.apache.org/jira/browse/OPENJPA-1602 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Affects Versions: 2.0.0 > Reporter: Fay Wang > Assignee: Pinaki Poddar > Priority: Critical > Fix For: 2.0.0 > > > The following test case executes query two times. > The sql generated for the first time: > sql = SELECT t0.KEYNAME, t0.KEYVAL FROM KEYGEN t0 WHERE (t0.KEYNAME = ?) optimize for 1 row FOR READ ONLY WITH RR USE AND KEEP UPDATE LOCKS > The sql generated for the second time: > sql = SELECT t0.KEYNAME, t0.KEYVAL FROM KEYGEN t0 WHERE (t0.KEYNAME = ?) > public void testKeyGen() { > EntityManager em = emf.createEntityManager(); > KeyGenEntity key = null; > em.getTransaction().begin(); > for (int i = 0;i < 2; i++) { > Query q = em.createNamedQuery("getStationKeyForUpdate"); > q.setLockMode(LockModeType.PESSIMISTIC_WRITE); > q.setParameter("keyname", keyName); > try { > key = (KeyGenEntity) q.getSingleResult(); > em.refresh(key); > } > catch (NoResultException e) { > // No keys found for this name - create a new one > int keyVal = 0; > key = new KeyGenEntity(keyName, keyVal); > em.persist(key); > em.lock(key, LockModeType.PESSIMISTIC_WRITE); > } > int keyVal = key.getKeyval(); > key.setKeyval(keyVal + 1); > } > em.getTransaction().commit(); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.