Content Repository

Schema Fields

Updated: July 17, 2023

The fields of a schema define the allowed content for the properties of the documents having this schema.

Field Types

A standard set of XSD types are allowed in Nuxeo schemas, and are mapped to Java and storage types as follows:

XSD TypeJava Type
xsd:stringString
xsd:normalizedStringString
xsd:longLong
xsd:unsignedLongLong
xsd:integerLong
xsd:intLong
xsd:unsignedIntLong
xsd:positiveIntegerLong
xsd:nonPositiveIntegerLong
xsd:nonNegativeIntegerLong
xsd:shortLong
xsd:unsignedShortLong
xsd:doubleDouble
xsd:floatDouble
xsd:decimalDouble
xsd:datetimeCalendar
xsd:dateCalendar
xsd:timeCalendar
xsd:booleanBoolean

Delta Updates

Since Nuxeo Platform 6.0 (NXP-15103) a new update model for Long properties is available using DeltaLong.

A DeltaLong is stored as a Long, but when used in the Java API to update a field (DocumentModel.setPropertyValue()) it specifies that the update should be done as an increment at the storage level rather than as a replacement of the old value. This allows for concurrent updates that don't lose value.

The standard usage to add a value "count" to a property "myprop" is: 

long count = 123;
Number oldValue = (Number) doc.getPropertyValue("myprop");
Number newValue = DeltaLong.deltaOrLong(oldValue, count);
doc.setPropertyValue("myprop", newValue);

DeltaLong.deltaOrLong(oldValue, count) should be used in preference over new DeltaLong(oldValue, count) because it can deal with the case where the old value is null or already a DeltaLong (the latter can happen if you're re-updating a property which hasn't been saved yet).

When using a SQL backend, this will emit code like:

UPDATE myschema SET myprop = myprop + 123 WHERE id = 'the-doc-id';

instead of:

UPDATE myschema SET myprop = 123 WHERE id = 'the-doc-id';

which you'll agree gives different results if two threads are executing it at the same time.

For a MongoDB backend, the update will be done using:

db.default.update(
   { "ecm:id": "the-doc-id" },
   { $inc: { "myprop": 123 } }
)

instead of :

db.default.update(
   { "ecm:id": "the-doc-id" },
   { "myprop": 123 }
)