title: Why DynamoDB java sdk doesn't allow always auto-generated keys?
body: <p>I'd like to implement change history for my objects in DynamoDB. Easy way of doing it would be to specify "object id" as hash and "updated time" as range key. However, java sdk doesn't allow annotating keys to be always autogenerated (changing the value without annotation convenience seems to work). Why?</p>
  
  <p>Example code:</p>
  
  <pre><code>@DynamoDBTable(tableName = "data")
  public class Person {
  
      public static void main(String[] args) {
          AmazonDynamoDBClient client = new AmazonDynamoDBClient()
                  .withEndpoint("http://localhost:8000");
          DynamoDBMapper mapper = new DynamoDBMapper(client);
  
          TableUtils.deleteTableIfExists(client, mapper.generateDeleteTableRequest(Person.class));
          TableUtils.createTableIfNotExists(client, mapper.generateCreateTableRequest(Person.class)
                  .withProvisionedThroughput(new ProvisionedThroughput(1L, 1L))
          );
  
          Person person = new Person();
          person.setPersonId("abc");
  
          mapper.save(person);
          mapper.save(person);
  
          TableUtils.deleteTableIfExists(client, mapper.generateDeleteTableRequest(Person.class));
      }
  
      @DynamoDBHashKey
      private String personId;
  
      @DynamoDBRangeKey
      @DynamoDBAutoGeneratedTimestamp
      private Long updated;
  
      public String getPersonId() {
          return personId;
      }
  
      public void setPersonId(String personId) {
          this.personId = personId;
      }
  
      public Long getUpdated() {
          return updated;
      }
  
      public void setUpdated(Long updated) {
          this.updated = updated;
      }
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>Exception in thread "main" com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: Field com.dynamodb.testpackage.Person[updated] must not have auto-generated key with ALWAYS strategy
      at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel$Builder.build(DynamoDBMapperFieldModel.java:797)
      at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$SchemaFactory.newTableModel(StandardModelFactories.java:118)
      at com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$SchemaFactory.getTableModel(StandardModelFactories.java:86)
      at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.getTableModel(DynamoDBMapper.java:401)
      at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.generateCreateTableRequest(DynamoDBMapper.java:2432)
      at com.dynamodb.testpackage.Person.main(Person.java:21)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  </code></pre>