Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 57772 invoked from network); 5 Dec 2008 22:48:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Dec 2008 22:48:17 -0000 Received: (qmail 14875 invoked by uid 500); 5 Dec 2008 22:48:29 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 14864 invoked by uid 99); 5 Dec 2008 22:48:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 14:48:29 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Fri, 05 Dec 2008 22:46:56 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5E771234C31E for ; Fri, 5 Dec 2008 14:47:44 -0800 (PST) Message-ID: <1617411767.1228517264385.JavaMail.jira@brutus> Date: Fri, 5 Dec 2008 14:47:44 -0800 (PST) From: "Michael Bouschen (JIRA)" To: jdo-dev@db.apache.org Subject: [jira] Commented: (JDO-619) API required for enabling/disabling FOR UPDATE locking for SELECTs In-Reply-To: <2128288071.1227785564201.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JDO-619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653960#action_12653960 ] Michael Bouschen commented on JDO-619: -------------------------------------- I think enabling/disabling FOR UPDATE locking for SELECTs is a useful feature and we should discuss how an API should look like to support this. One way is to specify this statically in the JDO metadata for a persistence capable class: e.g. add a boolean property useUpdateLock to the class metadata. This might help in most cases, but is not flexible enough, because it cannot be changed at runtime. Maybe we can add the same property useUpdateLock to the fetchplan and/or fetchgroup. This would allow FOR UPDATE locking being enabled and disabled dynamically at runtime. > API required for enabling/disabling FOR UPDATE locking for SELECTs > ------------------------------------------------------------------ > > Key: JDO-619 > URL: https://issues.apache.org/jira/browse/JDO-619 > Project: JDO > Issue Type: New Feature > Reporter: Marco > Fix For: JDO 2 maintenance release 3 > > > We - http://www.jfire.org - have some code where it is essential that objects read from the datastore are not manipulated by another transaction before they are modified and written to the datastore. In SQL, you use "SELECT ... FOR UPDATE" for this purpose, which locks the records included in the query result till the end of the transaction just like a write operation does. > In JDO, it is currently not yet possible to control whether reading causes read-locks (simple SELECT) or write-locks (SELECT ... FOR UPDATE). There are, however, vendor-specific solutions already. Thus, I'd like to first point out how DataNucleus solves this problem: > 1) The page RDBMS persistence properties > describes the property "datanucleus.rdbms.useUpdateLock" which applies to all queries. This would leave our code pure-JDO (not > DataNucleus-dependent), but it's unfortunately not what we need: Most of the time a lock is not required and this option would therefore > unnecessarily slow down our application. > 2) The page JDOQL shows this code snippet: > ((org.datanucleus.jdo.JDOTransaction)pm.currentTransaction()).setOption( > "transaction.serializeReadObjects", "true" > ); > This applies to all subsequent queries of one transaction. It works fine to enable/disable the option back and forth during the same transaction. Obviously, this is the most useful way to control the use of write-locks during read operations. > 3) Additionally, the same page mentions that you can set "datanucleus.rdbms.query.useUpdateLock" as a JDOQL extension. I assume > that's simply code like this: > query.addExtension("datanucleus.rdbms.query.useUpdateLock", "true"); > In contrast to solution (2), this only affects the single explicit query and no implicit queries which are used when accessing fields of the returned object(s). > Having explained all this, I'd like to request the following feature for the next JDO release (2.3): > Please extend javax.jdo.Transaction and add 2 methods: > void setSerializeReadObjects(boolean) > boolean isSerializeReadObjects() > This would make DataNucleus' solution (2) - see above - available via the JDO API. > Additionally, please extend javax.jdo.Query and add 2 new method: > void setSerializeReadObjects(boolean) > boolean isSerializeReadObjects() > This represents JDO-API for DataNucleus' solution (3) - see above. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.