Apache Gora (http://gora.apache.org/) provides an abstraction layer to work with various data storage engines. In this tutorial, we'll see how to use Gora with Apache Accumulo as the storage engine. I like to start projects with the Maven `pom.xml` file. So here is mine. It's important to
use Accumulo 1.4.3 instead of the newly released 1.5.0 because of an API incompatibility.
Otherwise, the `pom.xml` file is straightforward.

  <project ...>


      <name>POJOs in Accumulo</name>

          <!-- Dependency Versions -->
          <!-- Maven Plugin Dependencies -->



Now create a `src/main/resources/gora.properties` file configuring Gora by
specifying how to find Accumulo.


There are some important items to note. Firstly, we'll be using the MockInstance of
Accumulo so that you don't actually need to have it installed. Secondly, the password
needs to be blank if you are depending on Accumulo 1.4.3, change the password to
'''secret''' if using an earlier version.

That's all it takes to configure Gora. Now let's create a json file to define a very
simple object - a Person with just a first name. Create a json file with the

        "type": "record",
        "name": "Person",
        "namespace": "com.affy.generated",
        "fields": [
            {"name": "first", "type": "string"}

This is the simplest object I could think of. Not very useful for real applications, but
great for a simple proof-of-concept project.

The json file needs to be compiled into a Java file with the Gora compiler. Hopefully, you
have installed Gora and put its ```bin``` directory onto your path. Run the following to
generate the Java code:

    gora goracompiler src/main/avro/person.json src/main/java

One last bit of setup is needed. Create a ```src/main/resources/gora-accumulo-mapping.xml```
file with the following:

        <class table="people" keyClass="java.lang.String" name="com.affy.generated.Person">
            <field name="first" family="f" qualifier="q" />

Finally we get to the fun part. Actually writing a Java program to create, save, and
read a Person object. The code is straightforward so I won't explain it, just show it. Create
a src/main/java/com/affy/Create_Save_Read_Person_Driver.java file like this:

    package com.affy;

    import com.affy.generated.Person;
    import org.apache.avro.util.Utf8;
    import org.apache.gora.store.DataStore;
    import org.apache.gora.store.DataStoreFactory;
    import org.apache.gora.util.GoraException;
    import org.apache.hadoop.conf.Configuration;

    public class Create_Save_Read_Person_Driver {

        private void process() throws GoraException {
            Person person = new Person();
            person.setFirst(new Utf8("David"));
            System.out.println("Person written: " + person);

            DataStore<String, Person> datastore = DataStoreFactory.getDataStore(String.class, Person.class, new Configuration());
            if (!datastore.schemaExists()) {
            datastore.put("001", person);

            Person p = datastore.get("001");
            System.out.println("Person read: " + p);

        public static void main(String[] args) throws GoraException {
            Create_Save_Read_Person_Driver driver = new Create_Save_Read_Person_Driver();

This program has this output:

    Person written: com.affy.generated.Person@20c {
    Person read: com.affy.generated.Person@20c {

Hopefully, I'll be able to post more complex examples in the future.