google-app-engine - 如何在 objectify 中通过嵌套 Refs 进行查询

我有这样的结构:

//////Entity to be filtered
public class StockItem{
@Index
private Ref<StockItemTypeEntity> stockItemType;
} `enter code here`

//////Ref
public class StockItemTypeEntity{
@Index
private Ref<StockItemProductTypeEntity> productType;
}

我想像这样过滤 StockItem:

stockItemQuery = stockItemQuery.filter("stockItemType.productType", fitlerWrapper.getProductType());

但这行不通。如何使用嵌套引用进行过滤?

最佳答案

这是一个连接,底层数据存储不支持它。也就是说,如果您想执行联接,则必须自己执行。

根据数据的形状和您尝试执行的操作,一种常见的解决方案是将索引数据非规范化到父实体中(索引 StockItem 中的“productType”字段)。它确实需要保持数据同步。

https://stackoverflow.com/questions/49252700/

相关文章:

google-apps - 迄今为止的 Google 表格查询字符串

python - 如何对 Pandas RE .str.extract() 使用 RE OR 操作数

python - 如何使用 R 按列将 .csv 拆分为多个 .csv?

android - React Native StackNavigator 在重新进入时消失

jenkins - 如何在多分支管道项目中为每个分支级别的用户提供访问权限?

android - 在 test.Jar 中启动 startActivity() ,Cordova

amazon-web-services - 在 Looker 中可以进行分页吗?

c# - 可空类型 "int?"(包括问号)的默认值是多少?

asynchronous - 使用 async/await 进行异步 mocha 测试时遇到问题

python - LineString 和 Point 之间的距离