@enablescan何时需要DynamoDB存储库中?
创建DynamoDB存储库时,默认情况下是否需要ENABLESCAN注释?什么是功能?
@EnableScan
public interface DynamoRepository extends CrudRepository<Data, String> {
}
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> {
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的答案是否。仅当您想使用不是分区密钥的属性查询表时,才需要它。
例如:
假设您有一张名为“员工”的桌子,将分区密钥作为员工ID。您还具有诸如FirstName和LastName之类的属性。
在这种情况下,当您使用
FindbyId(雇员)
时,您不需要@enablescan
。但是,当您使用FindbyFirstName(“ John”)
时,您需要@enablescan
您可能已经注意到DynamoDB UI中可用的扫描功能。

@enablescan
与快照中显示的扫描功能相似。同样,您不需要
@enablescan
使用其分区键查询索引时。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 usefindByFirstName("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.