gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [4/5] gora git commit: GORA-362 Refactor gora-dynamodb to support avro serialization
Date Wed, 16 Mar 2016 14:56:12 GMT
GORA-362 Refactor gora-dynamodb to support avro serialization


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/655cd3aa
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/655cd3aa
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/655cd3aa

Branch: refs/heads/master
Commit: 655cd3aa846751f4805ef5e84ecd9193fe2c7aa2
Parents: 4f98503
Author: Lewis John McGibbney <lewis.j.mcgibbney@jpl.nasa.gov>
Authored: Fri Feb 26 17:48:49 2016 -0800
Committer: Lewis John McGibbney <lewis.j.mcgibbney@jpl.nasa.gov>
Committed: Fri Feb 26 17:48:49 2016 -0800

----------------------------------------------------------------------
 conf/log4j.properties                           |    2 +-
 .../gora/cassandra/store/CassandraStore.java    |    4 +-
 .../apache/gora/mapreduce/GoraRecordReader.java |   80 +-
 .../gora/mapreduce/PersistentDeserializer.java  |   14 +-
 .../gora/mapreduce/PersistentSerialization.java |   11 +-
 .../gora/mapreduce/PersistentSerializer.java    |    8 +-
 .../org/apache/gora/memory/store/MemStore.java  |    3 +-
 .../org/apache/gora/persistency/Persistent.java |    5 +-
 .../org/apache/gora/persistency/Tombstone.java  |   17 +
 .../gora/store/ws/impl/WSDataStoreBase.java     |   10 +-
 .../java/org/apache/gora/util/AvroUtils.java    |   10 +-
 .../org/apache/gora/util/ReflectionUtils.java   |   47 +-
 gora-dynamodb/pom.xml                           |  254 +++--
 gora-dynamodb/src/examples/avro/person.json     |   13 +
 .../gora/dynamodb/example/generated/Person.java |   79 ++
 .../dynamodb/example/generated/Webpage.java     |   72 ++
 .../apache/gora/examples/generated/person.java  |   97 --
 .../dynamodb/compiler/GoraDynamoDBCompiler.java |  399 +++----
 .../apache/gora/dynamodb/query/DynamoDBKey.java |   27 +-
 .../gora/dynamodb/query/DynamoDBQuery.java      |  327 ++++--
 .../gora/dynamodb/store/DynamoDBAvroStore.java  |  136 +++
 .../gora/dynamodb/store/DynamoDBFactory.java    |   49 +
 .../gora/dynamodb/store/DynamoDBMapping.java    |  297 ++---
 .../dynamodb/store/DynamoDBNativeStore.java     |  552 ++++++++++
 .../gora/dynamodb/store/DynamoDBStore.java      | 1036 +++++++-----------
 .../gora/dynamodb/store/DynamoDBUtils.java      |  229 ++++
 .../apache/gora/dynamodb/store/IDynamoDB.java   |   31 +
 .../src/test/conf/gora-dynamodb-mapping.xml     |   10 +-
 gora-dynamodb/src/test/conf/gora.properties     |    3 +
 .../gora/dynamodb/GoraDynamoDBTestDriver.java   |   89 +-
 .../gora/dynamodb/TestDynamoDBNativeStore.java  |  409 +++++++
 .../apache/gora/dynamodb/TestDynamoDBStore.java |  386 -------
 .../apache/gora/mongodb/store/MongoStore.java   |    3 +-
 pom.xml                                         |    4 +-
 34 files changed, 2862 insertions(+), 1851 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/conf/log4j.properties b/conf/log4j.properties
index 8293138..745d358 100644
--- a/conf/log4j.properties
+++ b/conf/log4j.properties
@@ -26,7 +26,7 @@ log4j.rootLogger=${gora.root.logger}
 #special logging requirements for some commandline tools
 log4j.logger.org.apache.gora.compiler.GoraCompiler=INFO,console
 log4j.logger.org.apache.avro.specific.SpecificCompiler=INFO,console
-log4j.logger.org.apache.gora.dynamodb.compiler.GoraDynamoDBCompiler=INFO,console
+log4j.logger.org.apache.gora.dynamodb.compiler.GoraDynamoDBCompiler=DEBUG,console
 log4j.logger.org.apache.gora.tutorial.log.LogManager=INFO,console
 log4j.logger.org.apache.gora.tutorial.log.LogAnalytics=INFO,console
 

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
----------------------------------------------------------------------
diff --git a/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java b/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
index bbed362..2619129 100644
--- a/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
+++ b/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
@@ -442,8 +442,8 @@ public class CassandraStore<K, T extends PersistentBase> extends DataStoreBase<K
   private Object getFieldValue(Schema fieldSchema, Type type, Object fieldValue ){
     switch(type) {
     case RECORD:
-      Persistent persistent = (Persistent) fieldValue;
-      Persistent newRecord = (Persistent) SpecificData.get().newRecord(persistent, persistent.getSchema());
+      PersistentBase persistent = (PersistentBase) fieldValue;
+      PersistentBase newRecord = (PersistentBase) SpecificData.get().newRecord(persistent, persistent.getSchema());
       for (Field member: fieldSchema.getFields()) {
         if (member.pos() == 0 || !persistent.isDirty()) {
           continue;

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/mapreduce/GoraRecordReader.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/mapreduce/GoraRecordReader.java b/gora-core/src/main/java/org/apache/gora/mapreduce/GoraRecordReader.java
index 2460246..832afc6 100644
--- a/gora-core/src/main/java/org/apache/gora/mapreduce/GoraRecordReader.java
+++ b/gora-core/src/main/java/org/apache/gora/mapreduce/GoraRecordReader.java
@@ -42,31 +42,31 @@ public class GoraRecordReader<K, T extends PersistentBase> extends RecordReader<
 
   protected Query<K,T> query;
   protected Result<K,T> result;
-  
+
   private GoraRecordCounter counter = new GoraRecordCounter();
-  
+
   public GoraRecordReader(Query<K,T> query, TaskAttemptContext context) {
     this.query = query;
 
     Configuration configuration = context.getConfiguration();
     int recordsMax = configuration.getInt(BUFFER_LIMIT_READ_NAME, BUFFER_LIMIT_READ_VALUE);
-    
+
     // Check if result set will at least contain 2 rows
     if (recordsMax <= 1) {
       LOG.info("Limit " + recordsMax + " changed to " + BUFFER_LIMIT_READ_VALUE);
       recordsMax = BUFFER_LIMIT_READ_VALUE;
     }
-    
+
     counter.setRecordsMax(recordsMax);
     LOG.info("gora.buffer.read.limit = " + recordsMax);
-    
+
     this.query.setLimit(recordsMax);
   }
 
   public void executeQuery() throws Exception {
     this.result = query.execute();
   }
-  
+
   @Override
   public K getCurrentKey() throws IOException, InterruptedException {
     return result.getKey();
@@ -80,47 +80,47 @@ public class GoraRecordReader<K, T extends PersistentBase> extends RecordReader<
   @Override
   public float getProgress() throws IOException, InterruptedException {
     try{
-	  return result.getProgress();
-  	}
- 	catch(Exception e){
- 		return 0;
- 	}
+      return result.getProgress();
+    }
+    catch(Exception e){
+      return 0;
+    }
   }
 
   @Override
   public void initialize(InputSplit split, TaskAttemptContext context)
-  throws IOException, InterruptedException { }
+      throws IOException, InterruptedException { }
 
   @Override
   public boolean nextKeyValue() throws IOException, InterruptedException {
-	  try{
-	    if (counter.isModulo()) {
-	      boolean firstBatch = (this.result == null);
-	      if (! firstBatch) {
-	        this.query.setStartKey(this.result.getKey());
-	        if (this.query.getLimit() == counter.getRecordsMax()) {
-	          this.query.setLimit(counter.getRecordsMax() + 1);
-	        }
-	      }
-	      if (this.result != null) {
-	        this.result.close();
-	      }
-	      
-	      executeQuery();
-	      
-	      if (! firstBatch) {
-	        // skip first result
-	        this.result.next();
-	      }
-	    }
-	    
-	    counter.increment();
-	    return this.result.next();
-	  }
-	  catch(Exception e){
-	    LOG.error("Error reading Gora records: {}", e.getMessage());
-	    throw new RuntimeException(e);
-	  }
+    try{
+      if (counter.isModulo()) {
+        boolean firstBatch = (this.result == null);
+        if (! firstBatch) {
+          this.query.setStartKey(this.result.getKey());
+          if (this.query.getLimit() == counter.getRecordsMax()) {
+            this.query.setLimit(counter.getRecordsMax() + 1);
+          }
+        }
+        if (this.result != null) {
+          this.result.close();
+        }
+
+        executeQuery();
+
+        if (! firstBatch) {
+          // skip first result
+          this.result.next();
+        }
+      }
+
+      counter.increment();
+      return this.result.next();
+    }
+    catch(Exception e){
+      LOG.error("Error reading Gora records: {}", e.getMessage());
+      throw new RuntimeException(e);
+    }
   }
 
   //@Override

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentDeserializer.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentDeserializer.java b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentDeserializer.java
index d592872..79eee42 100644
--- a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentDeserializer.java
+++ b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentDeserializer.java
@@ -24,7 +24,7 @@ import org.apache.avro.Schema;
 import org.apache.avro.io.BinaryDecoder;
 import org.apache.avro.io.DecoderFactory;
 import org.apache.avro.specific.SpecificDatumReader;
-import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.PersistentBase;
 import org.apache.gora.util.AvroUtils;
 import org.apache.hadoop.io.serializer.Deserializer;
 
@@ -33,19 +33,19 @@ import org.apache.hadoop.io.serializer.Deserializer;
 * with {@link BinaryDecoder}.
 */
 public class PersistentDeserializer
-   implements Deserializer<Persistent> {
+   implements Deserializer<PersistentBase> {
 
   private BinaryDecoder decoder;
-  private Class<? extends Persistent> persistentClass;
+  private Class<? extends PersistentBase> persistentClass;
   private boolean reuseObjects;
-  private SpecificDatumReader<Persistent> datumReader;
+  private SpecificDatumReader<PersistentBase> datumReader;
 
-  public PersistentDeserializer(Class<? extends Persistent> c, boolean reuseObjects) {
+  public PersistentDeserializer(Class<? extends PersistentBase> c, boolean reuseObjects) {
     this.persistentClass = c;
     this.reuseObjects = reuseObjects;
     try {
       Schema schema = AvroUtils.getSchema(persistentClass);
-      datumReader = new SpecificDatumReader<>(schema);
+      datumReader = new SpecificDatumReader<PersistentBase>(schema);
 
     } catch (Exception ex) {
       throw new RuntimeException(ex);
@@ -67,7 +67,7 @@ public class PersistentDeserializer
   public void close() throws IOException { }
 
   @Override
-  public Persistent deserialize(Persistent persistent) throws IOException {
+  public PersistentBase deserialize(PersistentBase persistent) throws IOException {
     return datumReader.read(reuseObjects ? persistent : null, decoder);
   }
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerialization.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerialization.java b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerialization.java
index 008e222..6ee1f4e 100644
--- a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerialization.java
+++ b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerialization.java
@@ -17,26 +17,25 @@
  */
 package org.apache.gora.mapreduce;
 
-import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.PersistentBase;
 import org.apache.hadoop.io.serializer.Deserializer;
 import org.apache.hadoop.io.serializer.Serialization;
 import org.apache.hadoop.io.serializer.Serializer;
 
-public class PersistentSerialization
-implements Serialization<Persistent> {
+public class PersistentSerialization implements Serialization<PersistentBase> {
 
   @Override
   public boolean accept(Class<?> c) {
-    return Persistent.class.isAssignableFrom(c);
+    return PersistentBase.class.isAssignableFrom(c);
   }
 
   @Override
-  public Deserializer<Persistent> getDeserializer(Class<Persistent> c) {
+  public Deserializer<PersistentBase> getDeserializer(Class<PersistentBase> c) {
     return new PersistentDeserializer(c, true);
   }
 
   @Override
-  public Serializer<Persistent> getSerializer(Class<Persistent> c) {
+  public Serializer<PersistentBase> getSerializer(Class<PersistentBase> c) {
     return new PersistentSerializer();
   }
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
index 4b1a646..b63de09 100644
--- a/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
+++ b/gora-core/src/main/java/org/apache/gora/mapreduce/PersistentSerializer.java
@@ -23,16 +23,16 @@ import java.io.OutputStream;
 import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.EncoderFactory;
 import org.apache.avro.specific.SpecificDatumWriter;
-import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.PersistentBase;
 import org.apache.hadoop.io.serializer.Serializer;
 
 /**
  * Hadoop serializer using Avro's {@link SpecificDatumWriter}
  * with {@link BinaryEncoder}.
  */
-public class PersistentSerializer implements Serializer<Persistent> {
+public class PersistentSerializer implements Serializer<PersistentBase> {
 
-  private SpecificDatumWriter<Persistent> datumWriter;
+  private SpecificDatumWriter<PersistentBase> datumWriter;
   private BinaryEncoder encoder;
   
   public PersistentSerializer() {
@@ -58,7 +58,7 @@ public class PersistentSerializer implements Serializer<Persistent> {
    * Do the serialization of the {@link Persistent} object
    */
   @Override
-  public void serialize(Persistent persistent) throws IOException {
+  public void serialize(PersistentBase persistent) throws IOException {
     datumWriter.setSchema(persistent.getSchema());
         
     datumWriter.write(persistent, encoder);

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java b/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
index e5f9aca..81dc3b9 100644
--- a/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
+++ b/gora-core/src/main/java/org/apache/gora/memory/store/MemStore.java
@@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 import org.apache.avro.Schema.Field;
-import org.apache.gora.persistency.Persistent;
 import org.apache.gora.persistency.impl.PersistentBase;
 import org.apache.gora.query.PartitionQuery;
 import org.apache.gora.query.Query;
@@ -170,7 +169,7 @@ public class MemStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
   /**
    * Returns a clone with exactly the requested fields shallowly copied
    */
-  private static<T extends Persistent> T getPersistent(T obj, String[] fields) {
+  private static<T extends PersistentBase> T getPersistent(T obj, String[] fields) {
     List<Field> otherFields = obj.getSchema().getFields();
     String[] otherFieldStrings = new String[otherFields.size()];
     for(int i = 0; i<otherFields.size(); i++ ){

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/persistency/Persistent.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/persistency/Persistent.java b/gora-core/src/main/java/org/apache/gora/persistency/Persistent.java
index dc45f79..bd520a9 100644
--- a/gora-core/src/main/java/org/apache/gora/persistency/Persistent.java
+++ b/gora-core/src/main/java/org/apache/gora/persistency/Persistent.java
@@ -20,14 +20,11 @@ package org.apache.gora.persistency;
 import java.util.List;
 
 import org.apache.avro.Schema.Field;
-import org.apache.avro.specific.SpecificRecord;
-
-import org.apache.gora.persistency.Dirtyable;
 
 /**
 * Objects that are persisted by Gora implements this interface.
 */
-public interface Persistent extends SpecificRecord, Dirtyable {
+public interface Persistent extends Dirtyable {
 
   public static String DIRTY_BYTES_FIELD_NAME = "__g__dirty";
 

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/persistency/Tombstone.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/persistency/Tombstone.java b/gora-core/src/main/java/org/apache/gora/persistency/Tombstone.java
index 61d85e9..527fd4e 100644
--- a/gora-core/src/main/java/org/apache/gora/persistency/Tombstone.java
+++ b/gora-core/src/main/java/org/apache/gora/persistency/Tombstone.java
@@ -1,3 +1,20 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.gora.persistency;
 
 /**

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java b/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
index e1d907b..494a09d 100644
--- a/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
+++ b/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
@@ -22,6 +22,7 @@ import java.util.Properties;
 
 import org.apache.gora.persistency.Persistent;
 import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
 import org.apache.gora.util.StringUtils;
 
 /**
@@ -54,6 +55,11 @@ implements DataStore<K, T>{
    * Properties object 
    */
   protected Properties properties;
+  
+  /** 
+   * Determines if an schema will be automatically created. 
+   */
+  protected boolean autoCreateSchema;
 
   /**
    * Default constructor
@@ -61,14 +67,16 @@ implements DataStore<K, T>{
   public WSDataStoreBase() {
   }
 
-  @Override
   /**
    * Initializes the web services backed data store
    */
+  @Override
   public void initialize(Class<K> keyClass, Class<T> persistentClass,
       Properties properties) {
     setKeyClass(keyClass);
     setPersistentClass(persistentClass);
+    autoCreateSchema = DataStoreFactory.getAutoCreateSchema(properties, this);
+    this.properties = properties;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/util/AvroUtils.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/util/AvroUtils.java b/gora-core/src/main/java/org/apache/gora/util/AvroUtils.java
index 86ab4a3..36b076e 100644
--- a/gora-core/src/main/java/org/apache/gora/util/AvroUtils.java
+++ b/gora-core/src/main/java/org/apache/gora/util/AvroUtils.java
@@ -33,7 +33,7 @@ import org.apache.avro.io.EncoderFactory;
 import org.apache.avro.reflect.ReflectData;
 import org.apache.avro.specific.SpecificDatumReader;
 import org.apache.avro.specific.SpecificDatumWriter;
-import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.PersistentBase;
 
 /**
  * An utility class for Avro related tasks
@@ -65,7 +65,7 @@ public class AvroUtils {
   /**
    * Returns the schema of the class
    */
-  public static Schema getSchema(Class<? extends Persistent> clazz)
+  public static Schema getSchema(Class<? extends PersistentBase> clazz)
       throws SecurityException, NoSuchFieldException, IllegalArgumentException,
       IllegalAccessException {
 
@@ -80,7 +80,7 @@ public class AvroUtils {
    *          the persistent object to get the fields names from
    * @return the field names
    */
-  public static String[] getPersistentFieldNames(Persistent persistent) {
+  public static String[] getPersistentFieldNames(PersistentBase persistent) {
     return getSchemaFieldNames(persistent.getSchema());
   }
 
@@ -100,10 +100,10 @@ public class AvroUtils {
     return fieldNames;
   }
 
-  public static <T extends Persistent> T deepClonePersistent(T persistent) {
+  public static <T extends PersistentBase> T deepClonePersistent(T persistent) {
     ByteArrayOutputStream bos = new ByteArrayOutputStream();
     BinaryEncoder enc = EncoderFactory.get().binaryEncoder(bos, null);
-    SpecificDatumWriter<Persistent> writer = new SpecificDatumWriter<>(
+    SpecificDatumWriter<PersistentBase> writer = new SpecificDatumWriter<>(
         persistent.getSchema());
     try {
       writer.write(persistent, enc);

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-core/src/main/java/org/apache/gora/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/gora-core/src/main/java/org/apache/gora/util/ReflectionUtils.java b/gora-core/src/main/java/org/apache/gora/util/ReflectionUtils.java
index a43dd64..bf3dc32 100644
--- a/gora-core/src/main/java/org/apache/gora/util/ReflectionUtils.java
+++ b/gora-core/src/main/java/org/apache/gora/util/ReflectionUtils.java
@@ -21,7 +21,7 @@ package org.apache.gora.util;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import org.apache.avro.specific.SpecificRecordBuilderBase;
-import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.PersistentBase;
 
 /**
  * Utility methods related to reflection
@@ -30,12 +30,12 @@ public class ReflectionUtils {
 
   public static Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
   public static Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-  
+
   /**
    * Returns the empty argument constructor of the class.
    */
   public static<T> Constructor<T> getConstructor(Class<T> clazz) 
-    throws SecurityException, NoSuchMethodException {
+      throws SecurityException, NoSuchMethodException {
     if(clazz == null) {
       throw new IllegalArgumentException("class cannot be null");
     }
@@ -43,12 +43,12 @@ public class ReflectionUtils {
     cons.setAccessible(true);
     return cons;
   }
-  
+
   /**
    * Returns whether the class defines an empty argument constructor.
    */
   public static boolean hasConstructor(Class<?> clazz) 
-  throws SecurityException, NoSuchMethodException {
+      throws SecurityException, NoSuchMethodException {
     if(clazz == null) {
       throw new IllegalArgumentException("class cannot be null");
     }
@@ -69,44 +69,47 @@ public class ReflectionUtils {
    * @param clazz the class of the object
    * @return a new instance of the object
    */
-  public static <T> T newInstance(Class<T> clazz) throws InstantiationException
-  , IllegalAccessException, SecurityException, NoSuchMethodException
-  , IllegalArgumentException, InvocationTargetException {
-    
+  public static <T> T newInstance(Class<T> clazz) 
+      throws InstantiationException, IllegalAccessException, 
+      SecurityException, NoSuchMethodException, IllegalArgumentException, 
+      InvocationTargetException {
+
     Constructor<T> cons = getConstructor(clazz);
-    
+
     return cons.newInstance(EMPTY_OBJECT_ARRAY);
   }
-  
+
   /**
    * Constructs a new instance of the class using the no-arg constructor.
    * @param classStr the class name of the object
    * @return a new instance of the object
    */
-  public static Object newInstance(String classStr) throws InstantiationException
-    , IllegalAccessException, ClassNotFoundException, SecurityException
-    , IllegalArgumentException, NoSuchMethodException, InvocationTargetException {
+  public static Object newInstance(String classStr) 
+      throws InstantiationException, IllegalAccessException, 
+      ClassNotFoundException, SecurityException, IllegalArgumentException, 
+      NoSuchMethodException, InvocationTargetException {
     if(classStr == null) {
       throw new IllegalArgumentException("class cannot be null");
     }
     Class<?> clazz = ClassLoadingUtils.loadClass(classStr);
     return newInstance(clazz);
   }
-  
+
   /**
    * Returns the value of a named static field
    */
   public static Object getStaticField(Class<?> clazz, String fieldName) 
-  throws IllegalArgumentException, SecurityException,
-  IllegalAccessException, NoSuchFieldException {
-    
+      throws IllegalArgumentException, SecurityException,
+      IllegalAccessException, NoSuchFieldException {
+
     return clazz.getField(fieldName).get(null);
   }
-  
+
   @SuppressWarnings("unchecked")
-  public static <T extends Persistent> SpecificRecordBuilderBase<T> classBuilder(Class<T> clazz) throws SecurityException
-    , NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+  public static <T extends PersistentBase> SpecificRecordBuilderBase<T> classBuilder(Class<T> clazz) 
+      throws SecurityException, NoSuchMethodException, IllegalArgumentException, 
+      IllegalAccessException, InvocationTargetException {
     return (SpecificRecordBuilderBase<T>) clazz.getMethod("newBuilder").invoke(null);
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/pom.xml
----------------------------------------------------------------------
diff --git a/gora-dynamodb/pom.xml b/gora-dynamodb/pom.xml
index a234c8f..c2356cb 100644
--- a/gora-dynamodb/pom.xml
+++ b/gora-dynamodb/pom.xml
@@ -14,137 +14,131 @@
    See the License for the specific language governing permissions and
    limitations under the License.
    -->
-   <modelVersion>4.0.0</modelVersion>
-   <parent>
-       <groupId>org.apache.gora</groupId>
-       <artifactId>gora</artifactId>
-       <version>0.6.1-SNAPSHOT</version>
-       <relativePath>../</relativePath>
-   </parent>
-   <artifactId>gora-dynamodb</artifactId>
-   <packaging>bundle</packaging>
-   <name>Apache Gora :: Dynamodb</name>
-       <url>http://gora.apache.org</url>
-   <description>The Apache Gora open source framework provides an in-memory data model and 
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.gora</groupId>
+    <artifactId>gora</artifactId>
+    <version>0.7-SNAPSHOT</version>
+    <relativePath>../</relativePath>
+  </parent>
+  <artifactId>gora-dynamodb</artifactId>
+  <packaging>bundle</packaging>
+  <name>Apache Gora :: Dynamodb</name>
+  <url>http://gora.apache.org</url>
+  <description>The Apache Gora open source framework provides an in-memory data model and 
    persistence for big data. Gora supports persisting to column stores, key value stores, 
    document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop MapReduce 
    support.</description>
-   <inceptionYear>2010</inceptionYear>
-   <organization>
-   	<name>The Apache Software Foundation</name>
-   	<url>http://www.apache.org/</url>
-   </organization>
-   <scm>
-   	<url>http://svn.apache.org/viewvc/gora/trunk/gora-dynamodb/</url>
-   	<connection>scm:svn:http://svn.apache.org/repos/asf/gora/trunk/gora-dynamodb/</connection>
-   	<developerConnection>scm:svn:https://svn.apache.org/repos/asf/gora/trunk/gora-dynamodb/</developerConnection>
-   </scm>
-   <issueManagement>
-   	<system>JIRA</system>
-   	<url>https://issues.apache.org/jira/browse/GORA</url>
-   </issueManagement>
-   <ciManagement>
-   	<system>Jenkins</system>
-   	<url>https://builds.apache.org/job/Gora-trunk/</url>
-   </ciManagement>
-   <properties>
-       <osgi.import>*</osgi.import>
-       <osgi.export>org.apache.gora.dynamodb*;version="${project.version}";-noimport:=true</osgi.export>
-   </properties>
-   <build>
-       <directory>target</directory>
-       <outputDirectory>target/classes</outputDirectory>
-       <finalName>${project.artifactId}-${project.version}</finalName>
-       <testOutputDirectory>target/test-classes</testOutputDirectory>
-       <testSourceDirectory>src/test/java</testSourceDirectory>
-       <sourceDirectory>src/main/java</sourceDirectory>
-       <resources>
-           <resource>
-               <directory>${basedir}/src/main/resources</directory>
-           </resource>
-           <resource>
-               <directory>${basedir}/conf</directory>
-           </resource>
-       </resources>
-       <testResources>
-            <testResource>
-                <directory>src/test/conf/</directory>
-                <includes>
-                    <include>**</include>
-                </includes>
-            </testResource>
-       </testResources>
-       <plugins>
-           <plugin>
-               <groupId>org.codehaus.mojo</groupId>
-               <artifactId>build-helper-maven-plugin</artifactId>
-               <version>${build-helper-maven-plugin.version}</version>
-               <executions>
-                   <execution>
-                       <phase>generate-sources</phase>
-                       <goals>
-                           <goal>add-source</goal>
-                       </goals>
-                       <configuration>
-                           <sources>
-                               <source>src/examples/java</source>
-                           </sources>
-                       </configuration>
-                   </execution>
-               </executions>
-           </plugin>
-           <plugin>
-               <groupId>org.apache.maven.plugins</groupId>
-               <artifactId>maven-surefire-plugin</artifactId>
-               <version>${maven-surfire-plugin.version}</version>
-               <configuration>
-                   <skipTests>true</skipTests>
-               </configuration>
-           </plugin>
-       </plugins>
-   </build>
-   <dependencies>
-       <!-- Gora Internal Dependencies -->
-       <dependency>
-           <groupId>org.apache.gora</groupId>
-           <artifactId>gora-core</artifactId>
-       </dependency>
-       <dependency>
-           <groupId>org.apache.gora</groupId>
-           <artifactId>gora-core</artifactId>
-           <type>test-jar</type>
-           <scope>test</scope>
-       </dependency>
-       
-       <!-- Amazon Dependencies -->
-       <dependency>
-           <groupId>com.amazonaws</groupId>
-	   <artifactId>aws-java-sdk</artifactId>
-       </dependency>
-       
-       <!-- Misc Dependencies -->
-       <dependency>
-            <groupId>org.jdom</groupId>
-            <artifactId>jdom</artifactId>
-       </dependency>
-        
-       <!-- Logging Dependencies -->
-       <dependency>
-           <groupId>org.slf4j</groupId>
-           <artifactId>slf4j-api</artifactId>
-       </dependency>
-       <dependency>
-           <groupId>org.slf4j</groupId>
-           <artifactId>slf4j-jdk14</artifactId>
-       </dependency>
-       <dependency>
-           <groupId>log4j</groupId>
-           <artifactId>log4j</artifactId>
-       </dependency>
-       <!-- Testing Dependencies -->
-       <dependency>
-           <groupId>junit</groupId>
-           <artifactId>junit</artifactId>
-       </dependency>
-    </dependencies>
+  <inceptionYear>2010</inceptionYear>
+  <organization>
+    <name>The Apache Software Foundation</name>
+    <url>http://www.apache.org/</url>
+  </organization>
+  <issueManagement>
+    <system>JIRA</system>
+    <url>https://issues.apache.org/jira/browse/GORA</url>
+  </issueManagement>
+  <ciManagement>
+    <system>Jenkins</system>
+    <url>https://builds.apache.org/job/Gora-trunk/</url>
+  </ciManagement>
+  <properties>
+    <osgi.import>*</osgi.import>
+    <osgi.export>org.apache.gora.dynamodb*;version="${project.version}";-noimport:=true</osgi.export>
+  </properties>
+  <build>
+    <directory>target</directory>
+    <outputDirectory>target/classes</outputDirectory>
+    <finalName>${project.artifactId}-${project.version}</finalName>
+    <testOutputDirectory>target/test-classes</testOutputDirectory>
+    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <sourceDirectory>src/main/java</sourceDirectory>
+    <resources>
+      <resource>
+        <directory>${basedir}/src/main/resources</directory>
+      </resource>
+      <resource>
+        <directory>${basedir}/conf</directory>
+      </resource>
+    </resources>
+    <testResources>
+      <testResource>
+        <directory>src/test/conf/</directory>
+        <includes>
+          <include>**</include>
+        </includes>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>${build-helper-maven-plugin.version}</version>
+        <executions>
+          <execution>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>src/examples/java</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skipTests>true</skipTests>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <!-- Gora Internal Dependencies -->
+    <dependency>
+      <groupId>org.apache.gora</groupId>
+      <artifactId>gora-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.gora</groupId>
+      <artifactId>gora-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Amazon Dependencies -->
+    <dependency>
+      <groupId>com.amazonaws</groupId>
+      <artifactId>aws-java-sdk</artifactId>
+    </dependency>
+
+    <!-- Misc Dependencies -->
+    <dependency>
+      <groupId>org.jdom</groupId>
+      <artifactId>jdom</artifactId>
+    </dependency>
+
+    <!-- Logging Dependencies -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/examples/avro/person.json
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/examples/avro/person.json b/gora-dynamodb/src/examples/avro/person.json
new file mode 100644
index 0000000..b8c4ca2
--- /dev/null
+++ b/gora-dynamodb/src/examples/avro/person.json
@@ -0,0 +1,13 @@
+{
+  "type": "record",
+  "name": "person",
+  "namespace": "org.apache.gora.examples.dynamodb.generated",
+  "fields" : [
+    {"name": "ssn", "type": "string"},
+    {"name": "date", "type": "string"}, 
+    {"name": "firstname", "type": "string"},
+    {"name": "lastname", "type": "string"},
+    {"name": "lastname", "type": "integer"}, 
+    {"name": "visitedplaces", "type": {"type":"array", "items": "string"}}
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Person.java
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Person.java b/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Person.java
new file mode 100644
index 0000000..471fb59
--- /dev/null
+++ b/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Person.java
@@ -0,0 +1,79 @@
+package org.apache.gora.dynamodb.example.generated;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.avro.Schema.Field;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.Tombstone;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
+
+@DynamoDBTable(tableName = "Person")
+public class Person implements Persistent {
+    private double ssn;
+
+    @DynamoDBHashKey(attributeName="ssn") 
+    public double getHashKey() {  return ssn; } 
+    public void setHashKey(double pSsn){  this.ssn = pSsn; }
+
+    private String date;
+
+    @DynamoDBRangeKey(attributeName="date") 
+    public String getRangeKey() { return date; } 
+    public void setRangeKey(String pDate){  this.date = pDate; }
+
+    private String lastName;
+    @DynamoDBAttribute(attributeName = "LastName")
+    public String getLastName() {  return lastName;  }
+    public void setLastName(String pLastName) {  this.lastName = pLastName;  }
+
+    private Set<String> visitedplaces;
+    @DynamoDBAttribute(attributeName = "Visitedplaces")
+    public Set<String> getVisitedplaces() {  return visitedplaces;  }
+    public void setVisitedplaces(Set<String> pVisitedplaces) {  this.visitedplaces = pVisitedplaces;  }
+
+    private double salary;
+    @DynamoDBAttribute(attributeName = "Salary")
+    public double getSalary() {  return salary;  }
+    public void setSalary(double pSalary) {  this.salary = pSalary;  }
+
+    private String firstName;
+    @DynamoDBAttribute(attributeName = "FirstName")
+    public String getFirstName() {  return firstName;  }
+    public void setFirstName(String pFirstName) {  this.firstName = pFirstName;  }
+
+
+    public void setNew(boolean pNew){}
+    public void setDirty(boolean pDirty){}
+    @Override
+    public void clear() { }
+    @Override
+    public Person clone() { return null; }
+    @Override
+    public boolean isDirty() { return false; }
+    @Override
+    public boolean isDirty(int fieldIndex) { return false; }
+    @Override
+    public boolean isDirty(String field) { return false; }
+    @Override
+    public void setDirty() { }
+    @Override
+    public void setDirty(int fieldIndex) { }
+    @Override
+    public void setDirty(String field) { }
+    @Override
+    public void clearDirty(int fieldIndex) { }
+    @Override
+    public void clearDirty(String field) { }
+    @Override
+    public void clearDirty() { }
+    @Override
+    public Tombstone getTombstone() { return null; }
+    @Override
+    public List<Field> getUnmanagedFields() { return null; }
+    @Override
+    public Persistent newInstance() { return new Person(); }
+}

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Webpage.java
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Webpage.java b/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Webpage.java
new file mode 100644
index 0000000..df9eb80
--- /dev/null
+++ b/gora-dynamodb/src/examples/java/org/apache/gora/dynamodb/example/generated/Webpage.java
@@ -0,0 +1,72 @@
+package org.apache.gora.dynamodb.example.generated;
+
+import java.util.List;
+
+import org.apache.avro.Schema.Field;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.Tombstone;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;
+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
+
+@DynamoDBTable(tableName = "Webpage")
+public class Webpage implements Persistent {
+    private String id;
+
+    @DynamoDBHashKey(attributeName="id") 
+    public String getHashKey() {  return id; } 
+    public void setHashKey(String pId){  this.id = pId; }
+
+    private String content;
+    @DynamoDBAttribute(attributeName = "Content")
+    public String getContent() {  return content;  }
+    public void setContent(String pContent) {  this.content = pContent;  }
+
+    private String common;
+    @DynamoDBAttribute(attributeName = "Common")
+    public String getCommon() {  return common;  }
+    public void setCommon(String pCommon) {  this.common = pCommon;  }
+
+    private String outlinks;
+    @DynamoDBAttribute(attributeName = "Outlinks")
+    public String getOutlinks() {  return outlinks;  }
+    public void setOutlinks(String pOutlinks) {  this.outlinks = pOutlinks;  }
+
+    private String parsedContent;
+    @DynamoDBAttribute(attributeName = "ParsedContent")
+    public String getParsedContent() {  return parsedContent;  }
+    public void setParsedContent(String pParsedContent) {  this.parsedContent = pParsedContent;  }
+
+
+    public void setNew(boolean pNew){}
+    public void setDirty(boolean pDirty){}
+    @Override
+    public void clear() { }
+    @Override
+    public Webpage clone() { return null; }
+    @Override
+    public boolean isDirty() { return false; }
+    @Override
+    public boolean isDirty(int fieldIndex) { return false; }
+    @Override
+    public boolean isDirty(String field) { return false; }
+    @Override
+    public void setDirty() { }
+    @Override
+    public void setDirty(int fieldIndex) { }
+    @Override
+    public void setDirty(String field) { }
+    @Override
+    public void clearDirty(int fieldIndex) { }
+    @Override
+    public void clearDirty(String field) { }
+    @Override
+    public void clearDirty() { }
+    @Override
+    public Tombstone getTombstone() { return null; }
+    @Override
+    public List<Field> getUnmanagedFields() { return null; }
+    @Override
+    public Persistent newInstance() { return new Webpage(); }
+}

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/examples/java/org/apache/gora/examples/generated/person.java
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/examples/java/org/apache/gora/examples/generated/person.java b/gora-dynamodb/src/examples/java/org/apache/gora/examples/generated/person.java
deleted file mode 100644
index 66f940b..0000000
--- a/gora-dynamodb/src/examples/java/org/apache/gora/examples/generated/person.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.apache.gora.examples.generated;
-import java.util.Set;
-import org.apache.gora.persistency.Persistent;
-import org.apache.gora.persistency.StateManager;
-import com.amazonaws.services.dynamodb.datamodeling.DynamoDBAttribute;
-import com.amazonaws.services.dynamodb.datamodeling.DynamoDBHashKey;
-import com.amazonaws.services.dynamodb.datamodeling.DynamoDBRangeKey;
-import com.amazonaws.services.dynamodb.datamodeling.DynamoDBTable;
-
-@DynamoDBTable(tableName = "person")
-public class person implements Persistent {
-    private String ssn;
-    private String date;
-
-    @DynamoDBHashKey(attributeName="ssn") 
-    public String getHashKey() {  return ssn; } 
-    public void setHashKey(String pSsn){  this.ssn = pSsn; }
-    @DynamoDBRangeKey(attributeName="date") 
-    public String getRangeKey() {  return date; } 
-    public void setRangeKey(String pDate){  this.date = pDate; }
-
-    private String lastName;
-    @DynamoDBAttribute(attributeName = "LastName")
-    public String getLastName() {  return lastName;  }
-    public void setLastName(String pLastName) {  this.lastName = pLastName;  }
-
-    private Set<String> visitedplaces;
-    @DynamoDBAttribute(attributeName = "Visitedplaces")
-    public Set<String> getVisitedplaces() {  return visitedplaces;  }
-    public void setVisitedplaces(Set<String> pVisitedplaces) {  this.visitedplaces = pVisitedplaces;  }
-
-    private double salary;
-    @DynamoDBAttribute(attributeName = "Salary")
-    public double getSalary() {  return salary;  }
-    public void setSalary(double pSalary) {  this.salary = pSalary;  }
-
-    private String firstName;
-    @DynamoDBAttribute(attributeName = "FirstName")
-    public String getFirstName() {  return firstName;  }
-    public void setFirstName(String pFirstName) {  this.firstName = pFirstName;  }
-
-
-    public void setNew(boolean pNew){}
-    public void setDirty(boolean pDirty){}
-    @Override
-    public StateManager getStateManager() { return null; }
-    @Override
-    public Persistent newInstance(StateManager stateManager) { return null; }
-    @Override
-    public String[] getFields() { return null; }
-    @Override
-    public String getField(int index) { return null; }
-    @Override
-    public int getFieldIndex(String field) { return 0; }
-    @Override
-    public void clear() { }
-    @Override
-    public person clone() { return null; }
-    @Override
-    public boolean isNew() { return false; }
-    @Override
-    public void setNew() { }
-    @Override
-    public void clearNew() { }
-    @Override
-    public boolean isDirty() { return false; }
-    @Override
-    public boolean isDirty(int fieldIndex) { return false; }
-    @Override
-    public boolean isDirty(String field) { return false; }
-    @Override
-    public void setDirty() { }
-    @Override
-    public void setDirty(int fieldIndex) { }
-    @Override
-    public void setDirty(String field) { }
-    @Override
-    public void clearDirty(int fieldIndex) { }
-    @Override
-    public void clearDirty(String field) { }
-    @Override
-    public void clearDirty() { }
-    @Override
-    public boolean isReadable(int fieldIndex) { return false; }
-    @Override
-    public boolean isReadable(String field) { return false; }
-    @Override
-    public void setReadable(int fieldIndex) { }
-    @Override
-    public void setReadable(String field) { }
-    @Override
-    public void clearReadable(int fieldIndex) { }
-    @Override
-    public void clearReadable(String field) { }
-    @Override
-    public void clearReadable() { }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java b/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
index cf03b33..be38e36 100644
--- a/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
+++ b/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
@@ -18,207 +18,241 @@
 
 package org.apache.gora.dynamodb.compiler;
 
+import static org.apache.gora.dynamodb.store.DynamoDBUtils.MAPPING_FILE;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
+import org.apache.commons.io.FilenameUtils;
 import org.apache.gora.dynamodb.store.DynamoDBMapping;
 import org.apache.gora.dynamodb.store.DynamoDBMapping.DynamoDBMappingBuilder;
+import org.apache.gora.util.GoraException;
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.input.SAXBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.amazonaws.services.dynamodb.model.KeySchema;
-import com.amazonaws.services.dynamodb.model.KeySchemaElement;
+import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
+import com.amazonaws.services.dynamodbv2.model.KeyType;
 
-/** Generate specific Java classes for defined schemas. */
+/** 
+ * Generate specific Java classes for defined schemas. 
+ * Different from the {@link org.apache.gora.compiler.GoraCompiler}, 
+ * which uses an .avsc or .json schema definition, this compiler 
+ * expects an XML schema file as input.
+ */
 public class GoraDynamoDBCompiler {
   private File dest;
   private Writer out;
   private static final Logger log = LoggerFactory.getLogger(GoraDynamoDBCompiler.class);
+  private String packageName;
 
+  /**
+   * GoraDynamoDBCompiler
+   * 
+   * @param File
+   *          where the data bean will be written.
+   */
   private GoraDynamoDBCompiler(File dest) {
-    this.dest = dest;                             // root directory for output
+    this.dest = dest;
   }
 
   /** Generates Java classes for a schema. */
   public static void compileSchema(File src, File dest) throws IOException {
-    log.info("Compiling " + src + " to " + dest );
+    log.info("Compiling {} to {}", src, dest);
     GoraDynamoDBCompiler compiler = new GoraDynamoDBCompiler(dest);
     DynamoDBMapping dynamoDBMap = compiler.readMapping(src);
-    if (dynamoDBMap.getTables().isEmpty())  throw new IllegalStateException("There are not tables defined.");
+    if (dynamoDBMap.getTables().isEmpty()) 
+      throw new IllegalStateException("There are no tables defined.");
 
-    for(String tableName : dynamoDBMap.getTables().keySet()){
-      compiler.compile(tableName, dynamoDBMap.getKeySchema(tableName), dynamoDBMap.getItems(tableName));
+    for(String tableName : dynamoDBMap.getTables().keySet()) {
+      compiler.compile(tableName, dynamoDBMap.getKeySchema(tableName), 
+          dynamoDBMap.getItems(tableName));
+      log.info("{} written without issues to {}", tableName, dest.getAbsolutePath());
     }
   }
 
   /**
-   * Method in charge of compiling a specific table using a key schema and a set of attributes
-   * @param pTableNameTable name
-   * @param pKeySchemaKey schema used
-   * @param pItemsList of items belonging to a specific table
+   * Method in charge of compiling a specific table using a key schema and a set 
+   * of attributes
+   * @param dest2 
+   * @param pTableNameTable 
+   *          name
+   * @param pKeySchemaKey 
+   *          schema used
+   * @param pItemsList 
+   *          of items belonging to a specific table
    */
-  private void compile(String pTableName, KeySchema pKeySchema, List<Map<String, String>> pItems){
-    // TODO define where the generated will go 
+  private void compile(String pTableName, ArrayList<KeySchemaElement> arrayList, Map<String, String> map){
     try {
       startFile(pTableName, pTableName);
-      setHeaders(null);
+      setHeaders(packageName);
       line(0, "");
       line(0, "@DynamoDBTable(tableName = \"" + pTableName + "\")");
       line(0, "public class " + pTableName + " implements Persistent {");
-      setKeyAttributes(pKeySchema, 2);
-      setKeyMethods(pKeySchema, 2);
-      setItems(pItems, 2);
-      setDefaultMethods(2);
+      for (KeySchemaElement pKeySchema : arrayList) {
+        setKeyAttributes(pKeySchema, map.get(pKeySchema.getAttributeName()), 2);
+        setKeyMethods(pKeySchema, map.get(pKeySchema.getAttributeName()), 2);
+        map.remove(pKeySchema.getAttributeName());
+      }
+      setItems(map, 2);
+      setDefaultMethods(2, pTableName);
       line(0, "}");
       out.flush();
       out.close();
     } catch (IOException e) {
-      log.error("Error while compiling table " + pTableName);
-      e.printStackTrace();
+      log.error("Error while compiling table {}",pTableName, e.getMessage());
+      throw new RuntimeException(e);
     }
   }
-  
+
   /**
    * Receives a list of all items and creates getters and setters for them
-   * @param pItemsThe items belonging to the table
-   * @param pIdenThe number of spaces used for identation
+   * @param pItemsThe 
+   *          items belonging to the table
+   * @param pIdenThe 
+   *          number of spaces used for identation
    * @throws IOException
    */
-  private void setItems(List<Map<String, String>> pItems, int pIden) throws IOException{
-    for(Map<String, String> item : pItems){
-      for (String itemName : item.keySet()){
-        String itemType = "String";
-        if (item.get(itemName).toString().equals("N"))
-          itemType = "double";
-        if (item.get(itemName).toString().equals("SS"))
-          itemType = "Set<String>";
-        if (item.get(itemName).toString().equals("SN"))
-          itemType = "Set<double>";
-        line(pIden, "private " + itemType + " " + itemName + ";");
-        setItemMethods(itemName, itemType, pIden);
-      }
+  private void setItems(Map<String, String> pItems, int pIden)
+      throws IOException {
+    for (String itemName : pItems.keySet()) {
+      String itemType = "String";
+      if (pItems.get(itemName).toString().equals("N"))
+        itemType = "double";
+      if (pItems.get(itemName).toString().equals("SS"))
+        itemType = "Set<String>";
+      if (pItems.get(itemName).toString().equals("SN"))
+        itemType = "Set<double>";
+      line(pIden, "private " + itemType + " " + itemName + ";");
+      setItemMethods(itemName, itemType, pIden);
     }
     line(0, "");
   }
-  
+
   /**
    * Creates item getters and setters
-   * @param pItemNameItem's name
-   * @param pItemTypeItem's type
-   * @param pIdenNumber of spaces used for indentation
+   * @param pItemNameItem
+   *          's name
+   * @param pItemTypeItem
+   *          's type
+   * @param pIdenNumber 
+   *          of spaces used for indentation
    * @throws IOException
    */
-  private void setItemMethods(String pItemName, String pItemType, int pIden) throws IOException{
-    line(pIden, "@DynamoDBAttribute(attributeName = \"" + camelCasify(pItemName) + "\")");
-    line(pIden, "public " + pItemType + " get" + camelCasify(pItemName) + "() {  return " + pItemName + ";  }");
-    line(pIden, "public void set" + camelCasify(pItemName) + "(" + pItemType + " p" + camelCasify(pItemName) + ") {  this." + pItemName + " = p"+ camelCasify(pItemName) +";  }");
+  private void setItemMethods(String pItemName, String pItemType, int pIden)
+      throws IOException {
+    line(pIden, "@DynamoDBAttribute(attributeName = \""
+        + camelCasify(pItemName) + "\")");
+    line(pIden, "public " + pItemType + " get" + camelCasify(pItemName)
+    + "() {  return " + pItemName + ";  }");
+    line(pIden, "public void set" + camelCasify(pItemName) + "(" + pItemType
+        + " p" + camelCasify(pItemName) + ") {  this." + pItemName + " = p"
+        + camelCasify(pItemName) + ";  }");
     line(0, "");
   }
-  
+
   /**
    * Creates key getters and setters 
-   * @param pKeySchemaThe key schema for a specific table
-   * @param pIdenNumber of spaces used for indentation
+   * @param pKeySchemaThe 
+   *          key schema for a specific table
+   * @param pIdenNumber 
+   *          of spaces used for indentation
    * @throws IOException
    */
-  private void setKeyMethods(KeySchema pKeySchema, int pIden) throws IOException{
-    KeySchemaElement hashKey = pKeySchema.getHashKeyElement();
-    KeySchemaElement rangeKey = pKeySchema.getRangeKeyElement();
+  private void setKeyMethods(KeySchemaElement pKeySchema, String attType,
+      int pIden) throws IOException {
     StringBuilder strBuilder = new StringBuilder();
+    attType = attType.equals("S") ? "String" : "double";
     // hash key
-    if(hashKey != null){
-      strBuilder.append("@DynamoDBHashKey(attributeName=\"" + hashKey.getAttributeName() + "\") \n");
-      strBuilder.append("    public String getHashKey() {  return " + hashKey.getAttributeName() + "; } \n");
-      strBuilder.append("    public void setHashKey(" + (hashKey.getAttributeType().equals("S")?"String ":"double "));
-      strBuilder.append("p" + camelCasify(hashKey.getAttributeName()) + "){  this." + hashKey.getAttributeName());
-      strBuilder.append(" = p" + camelCasify(hashKey.getAttributeName()) + "; }");
+    if (pKeySchema.getKeyType().equals(KeyType.HASH.toString())) {
+      strBuilder.append("@DynamoDBHashKey(attributeName=\""
+          + pKeySchema.getAttributeName() + "\") \n");
+      strBuilder.append("    public " + attType + " getHashKey() {  return "
+          + pKeySchema.getAttributeName() + "; } \n");
+      strBuilder.append("    public void setHashKey(" + attType + " ");
+      strBuilder.append("p" + camelCasify(pKeySchema.getAttributeName())
+      + "){  this." + pKeySchema.getAttributeName());
+      strBuilder.append(" = p" + camelCasify(pKeySchema.getAttributeName())
+      + "; }");
       line(pIden, strBuilder.toString());
     }
     strBuilder.delete(0, strBuilder.length());
     // range key
-    if(rangeKey != null){
-      strBuilder.append("@DynamoDBRangeKey(attributeName=\"" + rangeKey.getAttributeName() + "\") \n");
-      strBuilder.append("    public String getRangeKey() {  return " + rangeKey.getAttributeName() + "; } \n");
-      strBuilder.append("    public void setRangeKey(" + (rangeKey.getAttributeType().equals("S")?"String ":"double "));
-      strBuilder.append("p" + camelCasify(rangeKey.getAttributeName()) + "){  this." + rangeKey.getAttributeName());
-      strBuilder.append(" = p" + camelCasify(rangeKey.getAttributeName()) + "; }");
+    if (pKeySchema.getKeyType().equals(KeyType.RANGE.toString())) {
+      strBuilder.append("@DynamoDBRangeKey(attributeName=\""
+          + pKeySchema.getAttributeName() + "\") \n");
+      strBuilder.append("    public " + attType + " getRangeKey() { return "
+          + pKeySchema.getAttributeName() + "; } \n");
+      strBuilder.append("    public void setRangeKey(" + attType + " ");
+      strBuilder.append("p" + camelCasify(pKeySchema.getAttributeName())
+      + "){  this." + pKeySchema.getAttributeName());
+      strBuilder.append(" = p" + camelCasify(pKeySchema.getAttributeName())
+      + "; }");
       line(pIden, strBuilder.toString());
     }
     line(0, "");
   }
-  
+
   /**
    * Creates the key attributes within the generated class
-   * @param pKeySchemaKey schema
-   * @param pIdenNumber of spaces used for indentation
+   * @param pKeySchema
+   *          schema
+   * @param attType
+   *          attribute type
+   * @param pIden
+   *          of spaces used for indentation
    * @throws IOException
    */
-  private void setKeyAttributes(KeySchema pKeySchema, int pIden) throws IOException{
-    KeySchemaElement hashKey = pKeySchema.getHashKeyElement();
-    KeySchemaElement rangeKey = pKeySchema.getRangeKeyElement();
+  private void setKeyAttributes(KeySchemaElement pKeySchema, String attType,
+      int pIden) throws IOException {
     StringBuilder strBuilder = new StringBuilder();
-    // hash key
-    if(hashKey != null){
-      strBuilder.append("private " + (hashKey.getAttributeType().equals("S")?"String ":"double "));
-      strBuilder.append(hashKey.getAttributeName() + ";");
+    attType = attType.equals("S") ? "String " : "double ";
+    if (pKeySchema != null) {
+      strBuilder.append("private " + attType);
+      strBuilder.append(pKeySchema.getAttributeName() + ";");
       line(pIden, strBuilder.toString());
     }
     strBuilder.delete(0, strBuilder.length());
-    // range key
-    if(rangeKey != null){
-      strBuilder.append("private " + (rangeKey.getAttributeType().equals("S")?"String ":"double "));
-      strBuilder.append(rangeKey.getAttributeName() + ";");
-      line(pIden, strBuilder.toString());
-    }
     line(0, "");
   }
-  
+
   /**
    * Returns camel case version of a string
-   * @param sString to be camelcasified
+   * @param sString 
+   *          to be camelcasified
    * @return
    */
   private static String camelCasify(String s) {
-    return s.substring(0, 1).toUpperCase() + s.substring(1);
-  }
-
-  /** Recognizes camel case */
-  private static String toUpperCase(String s) {
-    StringBuilder builder = new StringBuilder();
-    for(int i=0; i<s.length(); i++) {
-      if(i > 0) {
-        if(Character.isUpperCase(s.charAt(i))
-         && Character.isLowerCase(s.charAt(i-1))
-         && Character.isLetter(s.charAt(i))) {
-            builder.append("_");
-        }
-      }
-      builder.append(Character.toUpperCase(s.charAt(i)));
-    }
-    return builder.toString();
+    return s.substring(0, 1).toUpperCase(Locale.getDefault()) + s.substring(1);
   }
 
   /**
    * Starts the java generated class file
-   * @param nameClass name
+   * @param nameClass 
+   *          name
    * @param space
+   *          spacing
    * @throws IOException
    */
   private void startFile(String name, String space) throws IOException {
-    File dir = new File(dest, space.replace('.', File.separatorChar));
+    String fullDest = FilenameUtils.normalize
+        (dest.getAbsolutePath() + File.separatorChar + packageName.replace('.', File.separatorChar));
+    File dir = new File(fullDest);
     if (!dir.exists())
       if (!dir.mkdirs())
         throw new IOException("Unable to create " + dir);
     name = cap(name) + ".java";
-    out = new OutputStreamWriter(new FileOutputStream(new File(dir, name)));
+    out = new OutputStreamWriter(new FileOutputStream(new File(dir, name)), Charset.defaultCharset());
 
   }
 
@@ -228,46 +262,36 @@ public class GoraDynamoDBCompiler {
    * @throws IOException
    */
   private void setHeaders(String namespace) throws IOException {
-    if(namespace != null) {
-      line(0, "package "+namespace+";\n");
+    if (namespace != null) {
+      line(0, "package " + namespace + ";\n");
     }
+    line(0, "import java.util.List;");
     line(0, "import java.util.Set;");
+    line(0, "");
+    line(0, "import org.apache.avro.Schema.Field;");
     line(0, "import org.apache.gora.persistency.Persistent;");
-    line(0, "import org.apache.gora.persistency.StateManager;");
-    line(0, "import com.amazonaws.services.dynamodb.datamodeling.DynamoDBAttribute;");
-    line(0, "import com.amazonaws.services.dynamodb.datamodeling.DynamoDBHashKey;");
-    line(0, "import com.amazonaws.services.dynamodb.datamodeling.DynamoDBRangeKey;");
-    line(0, "import com.amazonaws.services.dynamodb.datamodeling.DynamoDBTable;");
+    line(0, "import org.apache.gora.persistency.Tombstone;");
+    line(0, "import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;");
+    line(0, "import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;");
+    line(0, "import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;");
+    line(0, "import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;");
   }
 
   /**
    * Creates default methods inherited from upper classes
-   * @param pIdenNumber of spaces used for indentation
+   * @param pIden 
+   *          of spaces used for indentation
+   * @param tabName
+   *          table name
    * @throws IOException
    */
-  private void setDefaultMethods(int pIden) throws IOException {
+  private void setDefaultMethods(int pIden, String tabName) throws IOException {
     line(pIden, "public void setNew(boolean pNew){}");
     line(pIden, "public void setDirty(boolean pDirty){}");
     line(pIden, "@Override");
-    line(pIden, "public StateManager getStateManager() { return null; }");
-    line(pIden, "@Override");
-    line(pIden, "public Persistent newInstance(StateManager stateManager) { return null; }");
-    line(pIden, "@Override");
-    line(pIden, "public String[] getFields() { return null; }");
-    line(pIden, "@Override");
-    line(pIden, "public String getField(int index) {return null; }");
-    line(pIden, "@Override");
-    line(pIden, "public int getFieldIndex(String field) { return 0; }");
-    line(pIden, "@Override");
     line(pIden, "public void clear() { }");
     line(pIden, "@Override");
-    line(pIden, "public person clone() {return null; }");
-    line(pIden, "@Override");
-    line(pIden, "public boolean isNew() { return false; }");
-    line(pIden, "@Override");
-    line(pIden, "public void setNew() { }");
-    line(pIden, "@Override");
-    line(pIden, "public void clearNew() {}");
+    line(pIden, "public " + tabName + " clone() { return null; }");
     line(pIden, "@Override");
     line(pIden, "public boolean isDirty() { return false; }");
     line(pIden, "@Override");
@@ -287,29 +311,23 @@ public class GoraDynamoDBCompiler {
     line(pIden, "@Override");
     line(pIden, "public void clearDirty() { }");
     line(pIden, "@Override");
-    line(pIden, "public boolean isReadable(int fieldIndex) {return false; }");
-    line(pIden, "@Override");
-    line(pIden, "public boolean isReadable(String field) { return false; }");
-    line(pIden, "@Override");
-    line(pIden, "public void setReadable(int fieldIndex) { }");
-    line(pIden, "@Override");
-    line(pIden, "public void setReadable(String field) { }");
-    line(pIden, "@Override");
-    line(pIden, "public void clearReadable(int fieldIndex) { }");
+    line(pIden, "public Tombstone getTombstone() { return null; }");
     line(pIden, "@Override");
-    line(pIden, "public void clearReadable(String field) { }");
+    line(pIden, "public List<Field> getUnmanagedFields() { return null; }");
     line(pIden, "@Override");
-    line(pIden, "public void clearReadable() { }");
+    line(pIden, "public Persistent newInstance() { return new " + tabName + "(); }");
   }
 
   /**
    * Writes a line within the output stream
-   * @param indentNumber of spaces used for indentation
-   * @param textText to be written
+   * @param indentNumber 
+   *          of spaces used for indentation
+   * @param textText 
+   *          to be written
    * @throws IOException
    */
   private void line(int indent, String text) throws IOException {
-    for (int i = 0; i < indent; i ++) {
+    for (int i = 0; i < indent; i++) {
       out.append("  ");
     }
     out.append(text);
@@ -318,29 +336,38 @@ public class GoraDynamoDBCompiler {
 
   /**
    * Returns the string received with the first letter in uppercase
-   * @param nameString to be converted
+   * @param name 
+   *          to be converted
    * @return
    */
   static String cap(String name) {
-    return name.substring(0,1).toUpperCase()+name.substring(1,name.length());
+    return name.substring(0,1).toUpperCase(Locale.getDefault())
+        + name.substring(1,name.length());
   }
 
   /**
    * Start point of the compiler program
-   * @param argsReceives the schema file to be compiled and where this should be written
+   * @param argsReceives 
+   *          the schema file to be compiled and where this should be written
    * @throws Exception
    */
-  public static void main(String[] args) throws Exception {
-    if (args.length < 2) {
-      System.err.println("Usage: Compiler <schema file> <output dir>");
-      System.exit(1);
+  public static void main(String[] args) {
+    try {
+      if (args.length < 2) {
+        log.error("Usage: Compiler <schema file> <output dir>");
+        System.exit(1);
+      }
+      compileSchema(new File(args[0]), new File(args[1]));
+    } catch (Exception e) {
+      log.error("Something went wrong. Please check the input file.", e.getMessage());
+      throw new RuntimeException(e);
     }
-    compileSchema(new File(args[0]), new File(args[1]));
   }
 
   /**
    * Reads the schema file and converts it into a data structure to be used
-   * @param pMapFileThe schema file to be mapped into a table
+   * @param pMapFile
+   *          schema file to be mapped into a table
    * @return
    * @throws IOException
    */
@@ -352,50 +379,50 @@ public class GoraDynamoDBCompiler {
     try {
       SAXBuilder builder = new SAXBuilder();
       Document doc = builder.build(pMapFile);
-      
+
+      if (doc == null || doc.getRootElement() == null)
+        throw new GoraException("Unable to load " + MAPPING_FILE
+            + ". Please check its existance!");
+
       Element root = doc.getRootElement();
 
       List<Element> tableElements = root.getChildren("table");
-      for(Element tableElement : tableElements) {
-      
-      String tableName = tableElement.getAttributeValue("name");
-      long readCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
-      long writeCapacUnits = Long.parseLong(tableElement.getAttributeValue("readcunit"));
-    
-      mappingBuilder.setTableName(tableName);
-      mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits, writeCapacUnits);
-      log.debug("Basic table properties have been set: Name, and Provisioned throughput.");
-    
-      // Retrieving key's features
-      List<Element> fieldElements = tableElement.getChildren("key");
-      for(Element fieldElement : fieldElements) {
-        String keyName  = fieldElement.getAttributeValue("name");
-        String keyType  = fieldElement.getAttributeValue("type");
-        String keyAttrType  = fieldElement.getAttributeValue("att-type");
-        if(keyType.equals("hash"))
-          mappingBuilder.setHashKeySchema(tableName, keyName, keyAttrType);
-        else if(keyType.equals("hashrange"))
-          mappingBuilder.setHashRangeKeySchema(tableName, keyName, keyAttrType);
-      }
-      log.debug("Table key schemas have been set.");
-    
-      // Retrieving attributes
-        fieldElements = tableElement.getChildren("attribute");
-        for(Element fieldElement : fieldElements) {
-          String attributeName  = fieldElement.getAttributeValue("name");
+      boolean keys = false;
+      for (Element tableElement : tableElements) {
+
+        String tableName = tableElement.getAttributeValue("name");
+        long readCapacUnits = Long.parseLong(tableElement
+            .getAttributeValue("readcunit"));
+        long writeCapacUnits = Long.parseLong(tableElement
+            .getAttributeValue("writecunit"));
+        this.packageName = tableElement.getAttributeValue("package");
+
+        mappingBuilder.setProvisionedThroughput(tableName, readCapacUnits,
+            writeCapacUnits);
+        log.debug("Table properties have been set for name, package and provisioned throughput.");
+
+        // Retrieving attributes
+        List<Element> fieldElements = tableElement.getChildren("attribute");
+        for (Element fieldElement : fieldElements) {
+          String key = fieldElement.getAttributeValue("key");
+          String attributeName = fieldElement.getAttributeValue("name");
           String attributeType = fieldElement.getAttributeValue("type");
-          mappingBuilder.addAttribute(tableName, attributeName, attributeType, 0);
+          mappingBuilder.addAttribute(tableName, attributeName, attributeType);
+          // Retrieving key's features
+          if (key != null) {
+            mappingBuilder.setKeySchema(tableName, attributeName, key);
+            keys = true;
+          }
         }
-        log.info("Table attributes have been read.");
+        log.debug("Attributes for table '{}' have been read.", tableName);
+        if (!keys)
+          log.warn("Keys for table '{}' have NOT been set.", tableName);
       }
-
     } catch(IOException ex) {
-      log.info("Error while performing xml mapping.");
-      ex.printStackTrace();
-      throw ex;
-
+      log.error("Error while performing xml mapping.", ex.getMessage());
+      throw new RuntimeException(ex);
     } catch(Exception ex) {
-      ex.printStackTrace();
+      log.error("An error occured whilst reading the xml mapping file!", ex.getMessage());
       throw new IOException(ex);
     }
 

http://git-wip-us.apache.org/repos/asf/gora/blob/655cd3aa/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/query/DynamoDBKey.java
----------------------------------------------------------------------
diff --git a/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/query/DynamoDBKey.java b/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/query/DynamoDBKey.java
index b29786e..0aa8333 100644
--- a/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/query/DynamoDBKey.java
+++ b/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/query/DynamoDBKey.java
@@ -18,18 +18,22 @@
 
 package org.apache.gora.dynamodb.query;
 
-public class DynamoDBKey<H, R>  {
-  
+/**
+ * Class abstracting a composed DynamoDB key.
+ * @param <H>
+ * @param <R>
+ */
+public class DynamoDBKey<H, R> {  
   /**
    * Hash key used for a specific table 
    */
   private H hashKey;
-  
+
   /**
    * Range key used for a specific table
    */
   private R rangeKey;
-  
+
   /**
    * Gets hash key
    * @return
@@ -37,7 +41,7 @@ public class DynamoDBKey<H, R>  {
   public H getHashKey() {
     return hashKey;
   }
-  
+
   /**
    * Sets hash key
    * @param hashKey
@@ -45,7 +49,7 @@ public class DynamoDBKey<H, R>  {
   public void setHashKey(H hashKey) {
     this.hashKey = hashKey;
   }
-  
+
   /**
    * Gets range key
    * @return
@@ -53,7 +57,7 @@ public class DynamoDBKey<H, R>  {
   public R getRangeKey() {
     return rangeKey;
   }
-  
+
   /**
    * Sets range key
    * @param rangeKey
@@ -61,4 +65,13 @@ public class DynamoDBKey<H, R>  {
   public void setRangeKey(R rangeKey) {
     this.rangeKey = rangeKey;
   }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append('[').append(hashKey != null? hashKey.toString():":");
+    sb.append(rangeKey != null? ":" + rangeKey.toString():"");
+    sb.append(']');
+    return sb.toString();
+  }
 }


Mime
View raw message