Get in DynamoDB Using Java (Guide w/ Code Examples)

Provided by Rafal Wilinski
You can get an item in DynamoDB using the GetItemRequest
method. It requires the table name and they primary key of the table. An implementation of this method is shown below.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; import com.amazonaws.services.dynamodbv2.model.AttributeValue; import com.amazonaws.services.dynamodbv2.model.GetItemRequest; import com.amazonaws.services.dynamodbv2.model.GetItemResult; public class GetItemExample { public static void main(String[] args) { AmazonDynamoDB client = AmazonDynamoDBClientBuilder.defaultClient(); Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withN("123")); GetItemRequest request = new GetItemRequest() .withTableName("MyTable") .withKey(key); GetItemResult result = client.getItem(request); System.out.println(result.getItem()); } }
Similar Code Examples
- Conditional Update in DynamoDB Using Java
- Delete Table in DynamoDB Using Java
- Delete All Items in DynamoDB Using Java
- Batch Save Using DynamoDB Mapper
- Delete by Hashkey Using DynamoDB Mapper
- Get Item Request in DynamoDB Using Java
- Delete in DynamoDB Using Java
- Batch Load Using DynamoDB Mapper
- Batch Delete Using DynamoDB Mapper
- Delete Expression in DynamoDB Using Java
- Batch Put Item in DynamoDB Using Java
- Update Multiple Attributes in DynamoDB Using Java
- Get All Items from DynamoDB Using Java
- Batch Update Using DynamoDB Mapper
- Remove Attribute in DynamoDB Using Java
Better DynamoDB experience.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase