title: How do I annotate a dynamodb mapper with a secondary index?
body: <p>I'm trying to setup a Subscription table in dynamodb to keep track of who a user subscribes to. </p>
  
  <p>I have a table for Subscriptions with 2 String attributes, SubscriberID and UserID and would be setup like so (using names for simplicity):</p>
  
  <pre><code>[SubscriberID] ------ [UserID]
  
      Dave   ------ Steve
  
      Dave   ------ Josh
  
      Dave   ------ Cam
  
      Cam    ------ Dave
  
      Cam    ------ Justin
  </code></pre>
  
  <p>So it would be interpreted as: Dave subscribes to Steve, Josh, and Cam. Cam subscribes to Dave and Justin.. pretty simple.</p>
  
  <p>I have a primary key with SubscriberID as the partition key so I can query a user's subscriptions. I also have a secondary index called "getSubscribers" which has UserID as the partition key so I can query a user's subscribers. </p>
  
  <p>Each time I try to save a dynamodb mapper object it doesn't show up in my Subscriptions table, but my other tables w/ only 1 primary key are entering fine. </p>
  
  <p>I'm almost positive my problem is with my annotations on my Subscriber class, I've tried researching how this would properly be setup, the best I came up with was this</p>
  
  <pre><code>@DynamoDBTable(tableName = "starter-mobilehub-1604839252-Subscriptions ")
  public class Subscription {
  
    private String SubscriberID;
    private String UserID;
  
    @DynamoDBHashKey(attributeName = "SubscriberID")
    public String getSubscriberID() {return SubscriberID;}
    public void setSubscriberID(String UserID) {this.SubscriberID = UserID;}
  
    @DynamoDBIndexHashKey(globalSecondaryIndexName = "getSubscribers", attributeName = "UserID")
    public String getUserID() {return UserID;}
    public void setUserID(String UserID) {this.UserID = UserID;}
  
  }
  </code></pre>
  
  <p>I know that it's probably wrong, does anyone know how these annotations are supposed to be setup right? Any help would be awesome.</p>