Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 30213 invoked from network); 27 Jul 2009 20:43:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Jul 2009 20:43:47 -0000 Received: (qmail 67449 invoked by uid 500); 27 Jul 2009 20:44:51 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 67430 invoked by uid 500); 27 Jul 2009 20:44:51 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 67356 invoked by uid 99); 27 Jul 2009 20:44:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Jul 2009 20:44:51 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Jul 2009 20:44:42 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MVX3V-0005vY-8L for users@jackrabbit.apache.org; Mon, 27 Jul 2009 13:44:21 -0700 Message-ID: <24687924.post@talk.nabble.com> Date: Mon, 27 Jul 2009 13:44:21 -0700 (PDT) From: Gadbury To: users@jackrabbit.apache.org Subject: User Managed Transactions... MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: gadbury@googlemail.com X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I have a number of Jcr-based Daos that operate on my beans. In some cases, I have been using the session as a means to control a simple transaction. For example, I create a session and pass it to two different DAO create() methods. Only when all my Dao work is complete do I call session.save(). See my example code below: Session session = getSession(); JcrUserDao userDao = new JcrUserDao(); JcrProductDao productDao = new JcrProductDao(); userDao.create(aUser, session); productDao.create(aProduct, session); session.save(); The problem I have is that during a single transaction, I would like to create a multiple value property that contains strings for all node UUIDs create during the single transaction (i.e. hold 'weak' references to any newly created node UUIDs). I read in the specification that it is not safe to use a referenceable node's UUID until session.save() has been called and the changes have been persisted. However, with the above example, if I call save() before the two create methods have completed, I ruin my simple transaction. I have been reading the spec again regarding user managed transactions. Consider the following code: Session session = getSession(); // Get user transaction (for example, through JNDI) UserTransaction utx = ... JcrUserDao userDao = new JcrUserDao(); JcrProductDao productDao = new JcrProductDao(); utx.begin(); Node newUserNode = userDao.create(aUser, session); session.save(); String UUID = newUserNode.getUUID(); Node newProductNode = productDao.create(aProduct, session); session.save(); utx.commit(); After the first call to session.save(), would it then be safe to get a node's UUID? For example, in my JcrProductDao's create() method I create one Product node and then call another Dao to create N number of Element nodes. I would like my multiple value property of Product to hold all new Element node UUIDs. However, I also read this in the JCR 1.0 spec: "Note, however, that changes made in the transient storage are not recorded by a transaction. This means that a rollback will not revert changes made to the transient storage of the Session. After a rollback the Session object state will still contain any pending changes that were present before the rollback." I don't mind if I cannot revert a session's pending changes just as long as I can control when the changes are made persistent with a user managed transaction. Any help or advice would be greatly appreciated. Thanks for reading. -- View this message in context: http://www.nabble.com/User-Managed-Transactions...-tp24687924p24687924.html Sent from the Jackrabbit - Users mailing list archive at Nabble.com.