Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 12642 invoked from network); 28 Jul 2009 14:50:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 14:50:18 -0000 Received: (qmail 17749 invoked by uid 500); 28 Jul 2009 14:51:34 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 17715 invoked by uid 500); 28 Jul 2009 14:51:34 -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 17704 invoked by uid 99); 28 Jul 2009 14:51:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 14:51:34 +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 (nike.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; Tue, 28 Jul 2009 14:51:23 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MVo18-0006ZO-Uc for users@jackrabbit.apache.org; Tue, 28 Jul 2009 07:51:02 -0700 Message-ID: <24699832.post@talk.nabble.com> Date: Tue, 28 Jul 2009 07:51:02 -0700 (PDT) From: Gadbury To: users@jackrabbit.apache.org Subject: Re: User Managed Transactions... In-Reply-To: <24687924.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: gadbury@googlemail.com References: <24687924.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Sorry to bump the post but I thought I should clarify my question :) If I am within a user managed transaction's scope, and I have added a node and then call session.save(), is it safe to rely on that node's UUID or would I have to wait until the transaction has been committed? Here is the excerpt from the JCR 1.0 specification: =094.9.1.1 When UUIDs are Assigned =09In some client-server implementations the assignment of a permanent UUID may be done on the server.=20 =09In these cases it is not practical for a newly created referenceable nod= e to be given a UUID upon creation.=20 =09Rather, it makes more sense for the UUID to be assigned upon save of tha= t node.=20 =09In such cases a =E2=80=9Cdummy UUID=E2=80=9D may be assigned on creation= of a new node while the real UUID assignment takes place later, upon save. =09Applications should not, therefore, rely on the UUID of a node before th= at node is saved for the first time.=20 Thanks again. Kind regards, James Gadbury wrote: >=20 > Hi all, >=20 > I have a number of Jcr-based Daos. In some cases, I have been using the > session as a means to control a simple transaction. For example, I creat= e > 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 cod= e > below: >=20 >=20 > =09Session session =3D getSession(); >=20 > =09JcrUserDao userDao =3D new JcrUserDao(); > =09JcrProductDao productDao =3D new JcrProductDao(); >=20 > =09userDao.create(aUser, session); >=20 > =09productDao.create(aProduct, session); >=20 > =09session.save(); >=20 >=20 > 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 > created 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. >=20 > I have been reading the spec again regarding user managed transactions.= =20 > Consider the following code: >=20 >=20 > =09Session session =3D getSession(); >=20 > =09// Get user transaction (for example, through JNDI) > =09UserTransaction utx =3D ...=20 >=20 > =09JcrUserDao userDao =3D new JcrUserDao(); > =09JcrProductDao productDao =3D new JcrProductDao(); >=20 > =09utx.begin(); >=20 > =09Node newUserNode =3D userDao.create(aUser, session); >=20 > =09session.save(); >=20 > String UUID =3D newUserNode.getUUID(); >=20 > =09Node newProductNode =3D productDao.create(aProduct, session); >=20 > =09session.save(); >=20 > =09utx.commit(); >=20 >=20 > After the first call to session.save(), would it then be safe to get a > node's UUID? >=20 > For example, in my JcrProductDao's create() method, I am creating one > Product node and then create N number of ProductElement nodes by calling = a > JcrProductElementDao, again passing on the session. I would like a > multiple value property of a Product to hold all new Element node UUIDs. >=20 > However, I also read this in the JCR 1.0 spec: >=20 > =09"Note, however, that changes made in the transient storage are not > recorded by a transaction. > =09This means that a rollback will not revert changes made to the transie= nt > storage of the Session. > =09After a rollback the Session object state will still contain any pendi= ng > changes that were present before the rollback." >=20 > Does this mean that I shouldn't be using session and making transient > changes with user managed transactions? I don't mind if I cannot revert = a > session's pending changes just as long as I can control when the changes > are persisted and also reliably access a new node's UUID. >=20 > Any help or advice would be greatly appreciated. Thanks for reading. >=20 --=20 View this message in context: http://www.nabble.com/User-Managed-Transactio= ns...-tp24687924p24699832.html Sent from the Jackrabbit - Users mailing list archive at Nabble.com.