public class Paragraph
{
private String path;
private String text;
/* Add here the getter and setter methods */
}
## The JCR Structure
Here is the resulting JCR structure if the page is stored on the path
"/mysite/mypage1" and contains 2 paragraphs:
/mysite/page1
/mysite/page1/pageInfo
my:title = "This is my page title"
my:description = "This is my page description"
/mysite/page1/paragraphs
/mysite/page1/paragraphs/paragraph1
my:text = "This is the content of para1"
/mysite/page1/paragraphs/paragraph2
my:text = "This is the content of para2"
It is possible to have another kind of jcr structure by using other mapping
strategies. See the sections [Mapping Atomic Fields](mapping-atomic-fields.html)
, [Mapping Bean Fields]
, [Mapping Collection Fields]
to get more information on that.
## The Class Descriptors
When you decide to map a bean class, you have to create a new class
descriptor entry in the Persistence Manager descriptor file. Let's start
with the simplest class-descriptor:
This class descriptor maps the class
"org.apache.jackrabbit.ocm.testmodel.Paragraph" into the JCR type
"nt:unstructured". Each field-descriptor maps one bean field into a JCR
property. For example, the first field descriptor maps the java bean field
"text" into the jcr property called "myjcrtext". The second
field-descriptor is a specific case because it maps the jcr node path into
a bean field called "path" (see below the section "The Path Field").
You can find more information on the field-descriptors in the page [Mapping Atomic Fields](mapping-atomic-fields.html)
.
It is also possible to map a bean class to a particular JCR node type by
specifying the desired type in the attribute jcrType. The following
class-descriptor map the class
"org.apache.jackrabbit.ocm.testmodel.Paragraph" into the node type
"my:paragraph".
Here are the class-descriptors required to map the classes Page, PageInfo
and Paragraph:
In order to use correctly our example class with Apache Jackrabbit, you
should import the following node type definitions with the Jackrabbit API.
Of course, node types "my:Page" and "my:PageInfo" are also required.
We are currently building a node type management tools which can import the
node types from the class-descriptors.
## The Path Field
Each mapped class contains a mandatory field called the "path field". It
contains the JCR path associated to the object. For example, the following
descriptor specify the bean field "myPath" as the path field.