On Tue, Jul 28, 2009 at 4:51 PM, Gadbury<[email protected]> wrote: > 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: > > 4.9.1.1 When UUIDs are Assigned > > In some client-server implementations the assignment of a permanent > UUID > may be done on the server. > In these cases it is not practical for a newly created referenceable > node > to be given a UUID upon creation. > Rather, it makes more sense for the UUID to be assigned upon save of > that > node. > In such cases a “dummy UUID” may be assigned on creation of a new node > while the real UUID assignment takes place later, upon save. > Applications should not, therefore, rely on the UUID of a node before > that > node is saved for the first time.
The spec only talks about creating node vs. save(), but since in case of transactions a tx commit comes after a save(), you can be sure that the "final" UUID is assigned after your save - you don't have to wait for the commit. In Jackrabbit, UUIDs are already assigned when the node is created and don't change upon save. I added this implementation choice item to http://wiki.apache.org/jackrabbit/JcrSpecImplementation Regards, Alex -- Alexander Klimetschek [email protected]
