Suppose we have a document in a SQL storage that has a property attachedFile with the following structure:
<xs:element name="attachedFile" type="nxs:fileext" />
<xs:complexType name="fileext">
<xs:sequence>
<xs:element name="vignettes" type="nxs:vignettes" />
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="vignettes">
<xs:sequence>
<xs:element name="vignette" type="nxs:vignette" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="vignette">
<xs:sequence>
<xs:element name="width" type="xs:integer" />
<xs:element name="height" type="xs:integer" />
<xs:element name="content" type="nxs:content"/>
</xs:sequence>
</xs:complexType>
Build a Map that contains a non null empty list, set it as property value for "cmpf:attachedFile", save the document close the session, reopen a new session and refetch the document model . Trying to access the property "cmpf:attachedFile" logs the following stacktrace:
Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: java.lang.ClassCastException. message: org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
at org.nuxeo.ecm.core.api.model.impl.ListProperty.init(ListProperty.java:195)
at org.nuxeo.ecm.core.api.model.impl.ComplexProperty.init(ComplexProperty.java:182)
at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument.readOneProperty(SQLDocument.java:182)
at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument.readPropertyContainer(SQLDocument.java:165)
at org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument.readDocumentPart(SQLDocument.java:154)
at org.nuxeo.ecm.core.api.DocumentModelFactory.exportSchema(DocumentModelFactory.java:310)
And then fail with the exception:
org.nuxeo.ecm.core.api.model.PropertyNotFoundException: Property not found: cmpf:attachedFile. Document dont' implement schema: cmpf
at org.nuxeo.ecm.core.api.impl.DocumentModelImpl.getProperty(DocumentModelImpl.java:1455)
at org.nuxeo.ecm.core.storage.sql.coremodel.TestSQLRepositoryAPI.testComplexType(TestSQLRepositoryAPI.java:231)