Skip to content

Commit 464be97

Browse files
committed
Add example of TableSchema for immutable class.
1 parent 9b93b14 commit 464be97

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

services-custom/dynamodb-enhanced/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fully documented in the Javadoc of the interfaces referenced in these examples.
113113
Customer deletedCustomer = customerTable.deleteItem(Key.builder().partitionValue("a123").sortValue(456).build());
114114

115115
// Query
116-
PageIterable<Customer> customers = customerTable.query(equalTo(k -> k.partitionValue("a123")));
116+
PageIterable<Customer> customers = customerTable.query(keyEqualTo(k -> k.partitionValue("a123")));
117117

118118
// Scan
119119
PageIterable<Customer> customers = customerTable.scan();
@@ -220,6 +220,12 @@ The following requirements must be met for a class annotated with @DynamoDbImmut
220220
'builder' on the immutable class that takes no parameters and returns an instance of the builder class.
221221
1. The builder class must have a public method named 'build' that takes no parameters and returns an instance of the
222222
immutable class.
223+
224+
To create a TableSchema for your immutable class, use the static constructor method for immutable classes on TableSchema :
225+
226+
```java
227+
static final TableSchema<Customer> CUSTOMER_TABLE_SCHEMA = TableSchema.fromImmutableClass(Customer.class);
228+
```
223229
224230
There are third-party library that help generate a lot of the boilerplate code associated with immutable objects.
225231
The DynamoDb Enhanced client should work with these libraries as long as they follow the conventions detailed
@@ -276,7 +282,7 @@ key differences:
276282
application can then subscribe a handler to that publisher and deal
277283
with the results asynchronously without having to block:
278284
```java
279-
PagePublisher<Customer> results = mappedTable.query(r -> r.queryConditional(equalTo(k -> k.partitionValue("Smith"))));
285+
PagePublisher<Customer> results = mappedTable.query(r -> r.queryConditional(keyEqualTo(k -> k.partitionValue("Smith"))));
280286
results.subscribe(myCustomerResultsProcessor);
281287
// Perform other work and let the processor handle the results asynchronously
282288
```

0 commit comments

Comments
 (0)