Fork me on GitHub

Basic OCM operations

When you have created a new Object Content Manager in your application, you can use this component to insert, update, delete and retrieve objects. The class ‘Folder’ used in the following sections has to be annotated or defined in a xml file class descriptor.

This page describes only the main Object Content Manager methods. You can see the javadoc to get more information on the API. You can also read the tutorial 5' with Jackrabbit OCM to get more information on how to initialize the Object Content Manager.

Insert

Folder folder =  new Folder();
folder.setPath("/myfolder");
folder.set...(); // call the setter methods

ocm.insert(myFolder);

Retrieve and update an object

Folder folder = (Folder) persistenceManager.getObject(Folder.class, "/myfolder");
folder.set...(); // call the setter methods

ocm.update(myFolder);

Delete

ocm.remove("/test");

Save last changes

After some inserts, deletes and/or updates, you can call the method ocm.save() to apply your changes into the JCR repository.