Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
DynamoDBMappingException: no mapping for HASH key

When writing a DynamoDB Java App you can receive the 'no mapping for HASH key' error when writing or retrieving from a table if the table and its data model are not configured correctly. The full exception would be similar to:

com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: <YourClassNameHere>; no mapping for HASH key

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Make sure that your annotated mapped class's getters are declared public.

about 4 years ago · Santiago Trujillo Report

0

Two helpful things to check here:

1) For your main setter for your hash key value make sure that the @DynamoDBHashKey notation is correctly set. @DynamoDBAttribute is NOT the correct one to use for your table's main hash key and neither is @DynamoDBIndexHashKey.

2) Make sure that the hash key is defined in the table definition:

        CreateTableRequest createTableRequest = new CreateTableRequest()
                .withTableName("testtable")
                .withKeySchema(
                        new KeySchemaElement("id", KeyType.HASH)
                )
                .withProvisionedThroughput(new ProvisionedThroughput(1L, 1L))
                .withAttributeDefinitions(
                        new AttributeDefinition("id", "S")
                );

        CreateTableResult result = amazonDynamoDB.createTable(createTableRequest);

The above table definition creates a table 'testtable' with a main index or hash key variable titled id and the type is S for string.

Additionally, if you are using inheritance, make sure that you don't have two functions with the same name that override each other. Dynamo will use the top-level getter and this can cause issues.

about 4 years ago · Santiago Trujillo Report

0

If you are using @Data annotation (lombok.data), Try again after removing it and generate getters and setters for all the Attributes(including the primary_key/partition_key).

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!