-
1. Re: ConstraintViolationException when creating a node with a protected property
rhauch Jul 28, 2014 9:33 AM (in response to ma6rl)Protected properties are repository controlled so you really can't define custom node types with them. That's because the repository has to be able to know how to set them internally, and it won't know how to set the value of your custom protected property.
Perhaps the documentation was not clear; it was trying to say that when the "protected" attribute is absent from the property definition, then clients can set the property.
See the following section of the JCR 2.0 specification:
3.7.2.2 Protected
If an item I is declared protected it is repository-controlled.
If I is a node then, through the core write methods of JCR (see §10.2 Core Write
Methods),
- I cannot be removed,
- child nodes of I cannot be added, removed, or reordered,
- properties of I cannot be added or removed,
- the values of existing properties of I cannot be changed,
- the primary node type of I cannot be changed and
- mixin node types cannot be added to or removed from I.
If I is a property then, through the core write methods of JCR (see §10.2 Core Write Methods),
- I cannot be removed and
- the value of I cannot be changed.
Additionally, if I is a property, its being repository-controlled also implies that its value is under the control of the repository and can change at any time, before or after save. See §3.7.2.3.2 Auto-Created and Protected.