0

I am trying to update value of some property in xDB using XQuery, here is my transaction:

let $source := doc('/historicalresource')/HistoricalResourceData[id/@UUID = '0361513e-30fa-45e4-a73a-d05870b8a284']

let $res := $source/ResourceProperty[@PropertyName="cpu|limit"]/@PropertyValue

let $change := '21572'

return replace value of node $res with $change

After running this query I receive such error:

com.xhive.error.XhiveException: VERSION_ACCESS_DENIED: This document is versioned and can only be changed through a versioning operation

Indeed in my case historicalresource is a folder which may contain more than one document and all they have a version, like: v1.1 ,v1.2, etc..

How can I update the value of last version using xquery? How should I modify my query to be able to update desired value ?

Anahit Serobyan
  • 432
  • 1
  • 6
  • 17

2 Answers2

0

Finally, I have found the answer to my question, therefore adding it here:

There is no way to update xDB file using xQuery as it is version based system and xQuery cannot create a new version, but it could be done manually or automatically by some coding language (for example: java):

  1. Manually - by editing existing version in xDB, in that case a new version will be automatically created after saving any change to existing version of the file.
  2. Automatically - by checking out the file, making the change and submitting the change as a new version.
Anahit Serobyan
  • 432
  • 1
  • 6
  • 17
0

For versioned documents (on which XhiveLibraryChildIf.makeVersionable() was called), this is indeed the case: you have to check out the document first, then run the update query on the checked out copy, and finally check the new version in. For non-versioned documents, however, you can apply the update query directly.

Vojtěch Toman
  • 354
  • 3
  • 5