The collection-descriptor maps a collection attribute into JCR nodes.
Based on our model defined here, the following collection-descriptor is used to map the "paragraphs" field into the JCR node called "paragraphs".
<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Page" jcrNodeType="graffito:page"> <collection-descriptor fieldName="paragraphs" jcrName="paragraphs" elementClassName="org.apache.portals.graffito.jcr.testmodel.Paragraph" /> <!-- other field, bean and collection mapping here !--> </class-descriptor> <class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Paragraph" jcrNodeType="graffito:paragraph"> <field-descriptor fieldName="path" path="true" /> <field-descriptor fieldName="text" jcrName="graffito:text"/> </class-descriptor>
The collection-descriptor contains the elementClassName attribute which specify the collection element class.
Following our example, the resulting JCR structure can be :
/mysite/page1 /mysite/page1/paragraphs /mysite/page1/paragraphs/paragraph1 graffito:text = "This is the content of para1" /mysite/page1/paragraphs/paragraph2 graffito:text = ""This is the content of para2" ... other subnodes for page1 ...
Creating a subnode like this example (mysite/page1/paragraphs) is the default behaviour. See the section Reviewing the collection-descriptor to get other collection-field mapping strategies.