Title: Mapping Bean Fields The bean-descriptor maps a bean attribute into one JCR node (or a set of properties). Generally, this attribute is an object based on a custom class. Based on our model defined here, the following bean-descriptor is used to map the bean field "pageInfo" (PageInfo class) into the JCR node called "pageInfo". The PageInfo class has a corresponding class-descriptor in the mapping file. By this way, the Persistence Manager can map each PageInfo attributes. It is not necessary to specify the type in the bean-descriptor. The Persistence Manager uses the Java introspection to get information on the each bean fields. ## The JCR Structure Following our example, the resulting JCR structure is: /mysite/page1 /mysite/page1/pageInfo my:title = "This is my page title" my:description = "This is my page description" ... other subnodes for page1 ... By default, the persistence manager will create a subnode (/mysite/page1/pageInfo) for the bean-descriptor pageInfo. ## Using Another Bean Converter The OCM framework gives you the freedom to choose another kind of mapping for bean fields. For example, you can use a custom bean converter to access to the parent node (see the next section below). This can be done by writing your own bean converter class and reference this class in the bean-descriptor. ### Predefined Bean Converters Here is the list of existing custom bean converters:
Custom Bean Converter Class | Description |
---|---|
org.apache.jackrabbit.ocm.persistence.beanconverter.impl.ParentBeanConverterImpl | Map a bean field to the parent node. it is used to access to the parent object in read-only mode. See below the example based on a Folder object. |
org.apache.jackrabbit.ocm.persistence.beanconverter.impl.InlineBeanConverterImpl | Bean converter used to map some node properties into one nested bean field. The corresponding bean field is not associated to a subnode. |