-
1. Re: How to automatically set children versionable ?
rhauch Mar 9, 2012 10:51 AM (in response to akrambenaissi)Versioning in JCR is complicated, perhaps more than it needs to be.
Yes, a node must be "mix:versionable" before it can be checked in. But the rules that govern what the version snapshot will include are governed entirely by the "on-parent versioning" (OPV) attribute of the property definitions and child node definitions defined by the primary type and/or mixin types of the versionable node. The default OPV is "COPY", which means the corresponding properties and child nodes will be included in the version snapshot of the parent node, assuming the parent node is "mix:versionable". All the behavior of what happens when checking in a versionable node is spelled out in Section 15.2 of the JSR-283 specification, but the rules that are followed (with respect to the OPV) is specified in Section 3.13.9. Note that ModeShape implements "full versioning" (not "simple versioning").
Basically, when a versionable node A is checked in, all of the child nodes C will be handled based upon the C's child node definition 'Ac' (that is, the applicable child node definition from the primary type or mixin types) as follows:
- if the child node definition Ac has an OPV of "COPY", then the entire subgraph starting at node C will be copied into the version snapshot, regardless of the descendants' OPV settings
- if the child node definition Ac has an OPV of "VERSION", then the snapshot will simply contain a placeholder node (of primary type 'nt:versionedChild') pointing to the versioned child node
- if the child node definition Ac has an OPV of "ABORT", then an exception will be thrown
- if the child node definition Ac has an OPV of "IGNORE" or "INITIALIZE" or "COMPUTE", then the child node will not be included in the snapshop
Note that an OPV of COPY can be expensive if the subgraph of that child node contains a lot of descendants.