Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides Amazon DynamoDB patterns using AWS SDK for Java 2.x. Use when creating, querying, scanning, or performing CRUD operations on DynamoDB tables, working with indexes, batch operations, transactions, or integrating with Spring Boot applications.
.claude/skills/giuseppe-trisciuoglio-aws-sdk-java-v2-dynamodb/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 88% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 100% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 273% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 153% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 165% | 0% |
Provides DynamoDB patterns using AWS SDK for Java 2.x with Enhanced Client for type-safe CRUD, queries, batch operations, transactions, and Spring Boot integration.
pom.xml@DynamoDbBean annotationsDynamoDbTable (CRUD, query, scan, batch, transactions)Add to pom.xml:
xml<!-- Low-level DynamoDB client --> <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>dynamodb</artifactId> </dependency> <!-- Enhanced client (recommended) --> <dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>dynamodb-enhanced</artifactId> </dependency>
javaimport software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; DynamoDbClient dynamoDb = DynamoDbClient.builder() .region(Region.US_EAST_1) .build();
javaimport software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder() .dynamoDbClient(dynamoDb) .build();
java@DynamoDbBean public class Customer { @DynamoDbPartitionKey private String customerId; @DynamoDbAttribute("customer_name") private String name; private String email; @DynamoDbSortKey private String orderId; // Getters and setters }
For complex entity mapping with GSIs and custom converters, see Entity Mapping Reference.
java// Create or update item DynamoDbTable<Customer> table = enhancedClient.table("Customers", TableSchema.fromBean(Customer.class)); table.putItem(customer); // Get item Customer result = table.getItem(Key.builder().partitionValue(customerId).build()); // Update item return table.updateItem(customer); // Delete item table.deleteItem(Key.builder().partitionValue(customerId).build());
java// Get item with composite key Order order = table.getItem(Key.builder() .partitionValue(customerId) .sortValue(orderId) .build());
javaimport software.amazon.awssdk.enhanced.dynamodb.model.QueryConditional; QueryConditional queryConditional = QueryConditional .keyEqualTo(Key.builder() .partitionValue(customerId) .build()); List<Order> orders = table.query(queryConditional).items().stream() .collect(Collectors.toList());
javaimport software.amazon.awssdk.enhanced.dynamodb.Expression; Expression filter = Expression.builder() .expression("status = :pending") .putExpressionValue(":pending", AttributeValue.builder().s("PENDING").build()) .build(); List<Order> pendingOrders = table.query(r -> r .queryConditional(queryConditional) .filterExpression(filter)) .items().stream() .collect(Collectors.toList());
For detailed query patterns, see Advanced Operations Reference.
> Warning: Scan reads entire table and consumes read capacity for all items. Prefer Query operations with partition keys or GSIs whenever possible.
Validation before scan:
limit() to control capacity consumptionjava// Scan all items List<Customer> allCustomers = table.scan().items().stream() .collect(Collectors.toList()); // Scan with filter Expression filter = Expression.builder() .expression("points >= :minPoints") .putExpressionValue(":minPoints", AttributeValue.builder().n("1000").build()) .build(); List<Customer> vipCustomers = table.scan(r -> r.filterExpression(filter)) .items().stream() .collect(Collectors.toList());
javaimport software.amazon.awssdk.enhanced.dynamodb.model.*; List<Key> keys = customerIds.stream() .map(id -> Key.builder().partitionValue(id).build()) .collect(Collectors.toList()); ReadBatch.Builder<Customer> batchBuilder = ReadBatch.builder(Customer.class) .mappedTableResource(table); keys.forEach(batchBuilder::addGetItem); BatchGetResultPageIterable result = enhancedClient.batchGetItem(r -> r.addReadBatch(batchBuilder.build())); List<Customer> customers = result.resultsForTable(table).stream() .collect(Collectors.toList());
javaWriteBatch.Builder<Customer> batchBuilder = WriteBatch.builder(Customer.class) .mappedTableResource(table); customers.forEach(batchBuilder::addPutItem); BatchWriteItemEnhancedRequest request = BatchWriteItemEnhancedRequest.builder() .addWriteBatch(batchBuilder.build()) .build(); BatchWriteResult result = enhancedClient.batchWriteItem(request); // Validate: check for unprocessed items if (!result.writeResponsesForTable(table).isEmpty()) { // Retry unprocessed items with exponential backoff Map<String, AttributeValue> unprocessed = result.writeResponsesForTable(table).get(0) .unprocessedAttributes(); if (unprocessed != null && !unprocessed.isEmpty()) { enhancedClient.batchWriteItem(r -> r .addWriteBatch(WriteBatch.builder(Customer.class) .mappedTableResource(table) .addPutItemFromItem(unprocessed) .build())); } }
javapublic void placeOrderWithRetry(Order order, Customer customer, int maxRetries) { int attempt = 0; while (attempt < maxRetries) { try { enhancedClient.transactWriteItems(r -> r .addPutItem(customerTable, customer) .addPutItem(orderTable, order)); return; } catch (TransactionCanceledException e) { if (e.cancellationReasons().stream() .anyMatch(r -> r.code().equals("TransactionCanceledException") && r.message().contains("throughput"))) { attempt++; if (attempt < maxRetries) { try { Thread.sleep((long) Math.pow(2, attempt) * 100); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } } else { throw e; // Non-retryable error } } } }
javaTransactGetItemsEnhancedRequest request = TransactGetItemsEnhancedRequest.builder() .addGetItem(customerTable, customerKey) .addGetItem(orderTable, orderKey) .build(); List<Document> results = enhancedClient.transactGetItems(request);
java@Configuration public class DynamoDbConfiguration { @Bean public DynamoDbClient dynamoDbClient() { return DynamoDbClient.builder() .region(Region.US_EAST_1) .build(); } @Bean public DynamoDbEnhancedClient dynamoDbEnhancedClient(DynamoDbClient dynamoDbClient) { return DynamoDbEnhancedClient.builder() .dynamoDbClient(dynamoDbClient) .build(); } }
java@Repository public class CustomerRepository { private final DynamoDbTable<Customer> customerTable; public CustomerRepository(DynamoDbEnhancedClient enhancedClient) { this.customerTable = enhancedClient.table("Customers", TableSchema.fromBean(Customer.class)); } public void save(Customer customer) { customerTable.putItem(customer); } public Optional<Customer> findById(String customerId) { Key key = Key.builder().partitionValue(customerId).build(); return Optional.ofNullable(customerTable.getItem(key)); } }
For comprehensive Spring Boot integration patterns, see Spring Boot Integration Reference.
java@ExtendWith(MockitoExtension.class) class CustomerServiceTest { @Mock private DynamoDbClient dynamoDbClient; @Mock private DynamoDbEnhancedClient enhancedClient; @Mock private DynamoDbTable<Customer> customerTable; @InjectMocks private CustomerService customerService; @Test void saveCustomer_ShouldReturnSavedCustomer() { // Arrange when(enhancedClient.table(anyString(), any(TableSchema.class))) .thenReturn(customerTable); Customer customer = new Customer("123", "John Doe", "john@example.com"); // Act Customer result = customerService.saveCustomer(customer); // Assert assertNotNull(result); verify(customerTable).putItem(customer); } }
java@Testcontainers @SpringBootTest class DynamoDbIntegrationTest { @Container static LocalStackContainer localstack = new LocalStackContainer( DockerImageName.parse("localstack/localstack:3.0")) .withServices(LocalStackContainer.Service.DYNAMODB); @DynamicPropertySource static void configureProperties(DynamicPropertyRegistry registry) { registry.add("aws.endpoint", () -> localstack.getEndpointOverride(LocalStackContainer.Service.DYNAMODB).toString()); } @Autowired private DynamoDbEnhancedClient enhancedClient; @Test void testCustomerCRUDOperations() { // Test implementation } }
For detailed testing strategies, see Testing Strategies.
ProvisionedThroughputExceededattribute_not_exists(pk)java@Repository public class UserRepository { private final DynamoDbTable<User> userTable; public UserRepository(DynamoDbEnhancedClient enhancedClient) { this.userTable = enhancedClient.table("Users", TableSchema.fromBean(User.class)); } public User save(User user) { userTable.putItem(user); return user; } public Optional<User> findById(String userId) { Key key = Key.builder().partitionValue(userId).build(); return Optional.ofNullable(userTable.getItem(key)); } public void deleteById(String userId) { userTable.deleteItem(Key.builder().partitionValue(userId).build()); } }
javapublic boolean createIfNotExists(User user) { PutItemEnhancedRequest<User> request = PutItemEnhancedRequest.builder(User.class) .item(user) .conditionExpression("attribute_not_exists(userId)") .build(); try { userTable.putItemWithRequest(request); return true; } catch (ConditionalCheckFailedException e) { return false; // Item already exists } }
For detailed implementations, see the references folder:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | pass→pass | 6,048 | 5,581 | -8% | 1 | 1 | 0% | 1,146 | 4,279 | +273% | 0 | 0 | — |
case-01 | pass→pass | 10,926 | 10,294 | -6% | 1 | 1 | 0% | 2,098 | 5,305 | +153% | 0 | 0 | — |
case-02 | fail→fail | 22,046 | 18,597 | -16% | 1 | 1 | 0% | 4,161 | 6,904 | +66% | 0 | 0 | — |
case-03 | pass→pass | 9,297 | 7,504 | -19% | 1 | 1 | 0% | 1,769 | 4,689 | +165% | 0 | 0 | — |
case-04 | pass→pass | 4,958 | 4,290 | -13% | 1 | 1 | 0% | 988 | 4,159 | +321% | 0 | 0 | — |
case-06 | pass→pass | 6,466 | 4,415 | -32% | 1 | 1 | 0% | 1,277 | 4,120 | +223% | 0 | 0 | — |
case-07 | pass→pass | 11,722 | 7,060 | -40% | 1 | 1 | 0% | 2,311 | 4,731 | +105% | 0 | 0 | — |
case-08 | pass→pass | 11,442 | 6,392 | -44% | 1 | 1 | 0% | 2,327 | 4,364 | +88% | 0 | 0 | — |
case-09 | fail→pass | 17,153 | 10,987 | -36% | 1 | 1 | 0% | 2,684 | 5,039 | +88% | 0 | 0 | — |
case-10 | pass→pass | 5,684 | 4,202 | -26% | 1 | 1 | 0% | 931 | 3,954 | +325% | 0 | 0 | — |
case-11 | pass→pass | 5,998 | 4,140 | -31% | 1 | 1 | 0% | 978 | 3,946 | +303% | 0 | 0 | — |
case-12 | pass→pass | 14,080 | 14,482 | +3% | 1 | 1 | 0% | 2,645 | 6,074 | +130% | 0 | 0 | — |
case-13 | pass→pass | 15,576 | 10,073 | -35% | 1 | 1 | 0% | 2,570 | 5,073 | +97% | 0 | 0 | — |
case-14 | pass→pass | 15,097 | 12,262 | -19% | 1 | 1 | 0% | 2,489 | 5,573 | +124% | 0 | 0 | — |
case-15 | pass→pass | 12,585 | 9,942 | -21% | 1 | 1 | 0% | 2,492 | 5,349 | +115% | 0 | 0 | — |
case-16 | pass→pass | 13,725 | 9,653 | -30% | 1 | 1 | 0% | 2,673 | 5,119 | +92% | 0 | 0 | — |
case-17 | pass→pass | 13,611 | 11,361 | -17% | 1 | 1 | 0% | 2,669 | 5,632 | +111% | 0 | 0 | — |
case-18 | fail→pass | 16,613 | 15,829 | -5% | 1 | 1 | 0% | 3,213 | 6,437 | +100% | 0 | 0 | — |
case-19 | pass→pass | 3,876 | 1,597 | -59% | 1 | 1 | 0% | 604 | 3,460 | +473% | 0 | 0 | — |
case-20 | pass→pass | 3,169 | 2,159 | -32% | 1 | 1 | 0% | 556 | 3,613 | +550% | 0 | 0 | — |
case-21 | pass→pass | 4,783 | 3,846 | -20% | 1 | 1 | 0% | 835 | 3,941 | +372% | 0 | 0 | — |
case-22 | pass→pass | 4,790 | 4,593 | -4% | 1 | 1 | 0% | 887 | 4,120 | +364% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.