Carve - Sling Object Relational Mapper

Carve is a Sling Model Object Relational Mapper that aims to simplify writing to data with Sling Models. Jetpack Carve aims to provide an ORM-like experience like Hibernate offers for SQL-based systems.

Biggest advantages

Converting resources into Sling Models is not new. With Carve, Sling Models can write the containing information back to the repository. The location is configurable on the CarveModel annotation and the structure inside this location can be determined with a PolicyProvider:

  • SimplePathPolicyProvider: The node is named as the id. This should be used for limited amount of nodes. (e.g. /node-id)
  • BucketPathPolicyProvider: The node is structured in a 2-level bucket, where an MD5 hash is used to split nodes into buckets to avoid hundreds of nodes in 1 single folder. (e.g. /ABC/DEF/node-id)
  • DatePathPolicyProvider: The nodes are structured in a folder following the current date (e.g. /yyyy/MM/dd/HH/mm/node-id)

ChildResources are also supported, which will create a sub-node.

Ready to try this out?

Add the following dependency to your pom.xml file:


Want to learn more on how this works?

Create a Sling Model, which is also a CarveModel:



    @CarveModel(pathPolicyProvider = SimplePathPolicyProvider.class, location = "/etc/patches/completed")
    @Model(adaptables = Resource.class)
    public class PatchResult {
        private String id;
        private String status;
        public PatchResult() {
        public PatchResult(String id, String status) {
   = id;
            this.status = status;
        public String getId() {
            return id;
        public String getStatus() {
            return status;

Use the ModelManager to persist or retrieve the Sling Models:




    import be.ida_mediafoundry.jetpack.carve.manager.ModelManager;
    private ModelManager modelManager;

    public PatchResult getResult(String id) throws ModelManagerException {
        return modelManager.retrieve(PatchResult.class, id);

    public void createResult(String id) throws ModelManagerException {
        PatchResult patchResult = new PatchResult(id, "In Progress");