Jukka Zitting wrote:
Hi,

On Jan 16, 2008 9:27 PM, Dan Diephouse <[EMAIL PROTECTED]> wrote:
  
I have to lock the parent node before I can add child nodes? How does that
help the situation? Then I have one thread that fails while the other
succeeds.

Lets say I have a node /spreadsheets and then I have two users using my web
interface and they both add a spreadsheet to the repository at the same
time. And spreadsheet nodes are represented by /spreadsheets/spreadsheet .
Are you saying thats not possible?
    

Jackrabbit handles such concurrent additions nicely as long as the
added child nodes have separate names. See JCR-584 [1] for the
details.

Unfortunately this does not currently work with same name siblings. If
I recall correctly there were some tricky semantic issues on how such
cases should really be handled.

Have you considered not using same name siblings in your content mode.
See [2] and the related mailing list thread [3] for a rationale why
locally (within a parent) unique node names are considered a better
solution.

  
Thanks. Follow up question: My data has no unique id or anything associated with it. So I'm going to have to generate an id then.

I can do an increment type thing like this:

public Node getNode(int nodeName, Node parent) {
  try { return parent.addNode(new Integer(nodeName).toString()) }
  catch (ItemExistsException e) { return getNode(nodeName+1); }
}

Lets say I have two open transactions where this is occurring at the same time. Will Tx#2 see that #1 has added a node named "1" and get an ItemExistsException even though I haven't committed Tx#1?

Are there any bundled utilities within jackrabbit that can create unique ids across a cluster? Should I just use UUIDs?

- Dan
-- 
Dan Diephouse
MuleSource
http://mulesource.com | http://netzooid.com/blog

Reply via email to