title: DynamoDBMappingException: no RANGE key value present
body: <p>I am new to <code>NoSQL</code> and <code>Amazon Dynamo DB</code>. I am trying to retreive a user by <code>username</code> first from a <code>DynamoDB</code> <code>UserMaster</code> table.</p>
  <p>I have a table <code>UserMaster</code> with 5 attributes(<code>username</code>, <code>correct-hash</code>, <code>email</code>, <code>lastLogin</code>, <code>role</code>), each of type <code>String</code> and I have a corresponding <code>UsermasterBean</code> mapped to the table <code>UserMaster</code>. <code>UserMaster</code> table's Partition Key(Hashkey) is  <code>username</code> and <code>Sort key(Range Key)</code> is <code>correct-hash</code></p>
  <p><strong>UsermasterBean</strong></p>
  <pre><code>    @DynamoDBTable(tableName = &quot;UserMaster&quot;)
      public class UsermasterBean {
      
      private String username;
      private String correctHash;
      private String email;
      private String lastLogin;
      private String role;
      
      @DynamoDBHashKey(attributeName = &quot;username&quot;)
      @DynamoDBAttribute(attributeName = &quot;username&quot;)
      public String getUsername() {
          return username;
      }
      
      @DynamoDBRangeKey(attributeName = &quot;correct-hash&quot;)
      @DynamoDBAttribute(attributeName = &quot;correct-hash&quot;)
      public String getCorrectHash() {
          return correctHash;
      }
      
      @DynamoDBAttribute(attributeName = &quot;email&quot;)
      public String getEmail() {
          return email;
      }
      
      @DynamoDBAttribute(attributeName = &quot;last-login&quot;)
      public String getLastLogin() {
          return lastLogin;
      }
      
      @DynamoDBAttribute(attributeName = &quot;role&quot;)
      public String getRole() {
          return role;
      }
      
      public void setUsername(String username) {
          this.username = username;
      }
      ....
      ....
     }
  </code></pre>
  <p><strong>Retrieve data from UI:</strong></p>
  <pre><code>UsermasterBean usermasterBean = new UsermasterBean();
  UsermasterDao usermasterDao = new UsermasterDao();
  
  usermasterBean.setUsername(username.getValue()); // Get the username from UI form
  final String inputtedPassword = password.getValue(); // Get the password from UI form
  
  UsermasterBean retrievedUserBean = usermasterDao.findByUsernameAndPassword(usermasterBean,inputtedPassword);
  </code></pre>
  <p><strong>Validate User:</strong></p>
  <pre><code>public UsermasterBean findByUsernameAndPassword(final UsermasterBean usermasterBean, final String inputtedPassword)
              throws IOException {
          AmazonDynamoDBClientHandler amazonDynamoDBClientHandler = AmazonDynamoDBClientHandler.getNewInstance();
          UsermasterBean retrievedUser;
          try {
              AmazonDynamoDB amazonDynamoDB = amazonDynamoDBClientHandler.createNewClient();
              DynamoDBMapper dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB);
              retrievedUser = dynamoDBMapper.load(usermasterBean.getClass(), usermasterBean.getUsername());
              System.out.println(&quot;RETRIEVED CORRECT-HASH FROM DATABASE: &quot; + retrievedUser.getCorrectHash()); // Check if hash retrieved is correct for this user.
  
              // PasswordUtilityManager.verifyPassword(inputtedPassword,retrievedUser.getCorrectHash());
          } catch (IOException ioException) {
              throw ioException;
          } finally {
              amazonDynamoDBClientHandler.shutdownClient();
          }
          return retrievedUser;
  }
  </code></pre>
  <p><strong>Problem:</strong></p>
  <p><code>retrievedUser = dynamoDBMapper.load(usermasterBean.getClass(), usermasterBean.getUsername());</code> throws <code>com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException</code></p>
  <p>I am expecting <code>retrievedUser.getCorrectHash()</code> should display the hashed password stored in database as a <code>String</code> so that I can verify if the inputted password creates the same hash as retrieved from the database.</p>