When creating a DynamoDB repository, is the EnableScan annotation required by default? What is it's functionality?
@EnableScan
public interface DynamoRepository extends CrudRepository<Data, String> {
}
The short answer is No. You don't need @EnableScan
all the time. You need it only if you want to query the table with an attribute that's not a partition key.
For Example: Let's say you have a Table called Employee with Partition Key as employee id. You also have attributes like firstName and lastName.
In this case when you use findById(employeeId)
you don't need @EnableScan
. But when you use findByFirstName("John")
then you need @EnableScan
You might have noticed the scan feature that's available in DynamoDB UI. @EnableScan
is similar to the scan feature shown in the snapshot.
Likewise, you don't need @EnableScan
when you are querying an index with its partition Key.