Searching and Traversing Version Storage

Exposing the version storage as content in the workspace allows the stored versions and their associated version meta-data to be searched or traversed just like any other part of the workspace.

This allows, for example, an application to search for a particular version according to the value of its properties. In a repository that supports SQL queries, the following query would return all versions where productName is “Car” and price is greater than 30,000:

FROM nt:version
WHERE productName = "Car"
AND price > "30000"
AND jcr:path LIKE

When an nt:versionHistory or nt:version node is acquired through a query or directly through a getNode, the actual Java type of the returned object must be VersionHistory (in the case nt:versionHistory nodes) or Version (in the case of nt:version nodes). This allows the application to then cast the returned object down to either Version or VersionHistory and then use it in methods that take those types, for example Node.restore(Version version, boolean removeExisting).