The Persistence Manager

The main component in our framework is the Persistence manager. It converts an object graph into JCR nodes and properties and vice versa.

How the Persistence Manager is working ?

Thanks to its Mapping Descriptor file, the Persistence Manager can use the more appropriate mapping strategy for each object. This Mapping Descriptor file contains one class descriptor for each mapped class. Each class descriptor contains mapping information for the corresponding class attributes. The descriptor file contains also information on object associations, inheritance mapping strategy, lazy loading, cache strategy, ...

There are 4 attributes/fields "types" :

  1. Simple fields : primitive data types and simple objects (String, Long, Double, ...) . Those fields are mapped into JCR properties.
  2. Bean fields : One class can contain an 1..1 association to another bean. In this case, the attribute is a custom object. Those fields are mapped into JCR nodes.
  3. Collection fields : One class can contain an 1..n association to a collection of beans (or Map). Those fields are mapped into a collection of JCR nodes.
  4. Reference field : One good example to understand the "reference" type is the Folder concept. A folder "B" can have an attribute called "parentFolder" which is a simple field pointing to the parent folder "A" . Of course, in a JCR repository, it is a nonsense for persist this "parentFolder" attribute into a "B" subnode. Another interesting example are links made between cms objects (folders, documents, ...).

Of course, all those "mapping types" imply different mapping algorithms.

The Mapping Descriptor File

The mapping descriptor is an xml file with the following structure :

 				
<?xml version="1.0" encoding="UTF-8"?>
										
<graffito-jcr>
										
	<class-descriptor className="[Reference to a class to map]" ...">
								
		... Contains the references to the class attributes ...
										
	</class-descriptor>
									
	... other class descritptors ....
	
</graffito-jcr>										
				

The root element is "graffito-jcr" and it contains one or more "class-descriptor". As you can see in the sections "Mapping Strategies" and "Advanced Mapping Strategies", each class-descriptor contains the mapping information used for each class attributes.

It is possible to have severals xml files. See the Sectup section to get more information on how to initialize the Persistence Manager.