java - 当我使用多个关系路径时,Ebean 查询运算符“Fetch”不起作用
问题描述
据我了解,当我使用fetch
查询对象时,Ebean 将尝试使用连接来获取关系。
例如
Ebean.find(ProjectRequest.class)
.fetch("attachments")
.findList();
这在尝试获取一个关系时按预期工作。
但是,当我尝试处理fetch
多个关系时,它不会使用连接查询任何关系,而是使用单独的查询获取所有关系。
例如
Ebean.find(ProjectRequest.class)
.fetch("projectConstructionCosts")
.fetch("attachments")
.fetch("projectRequestComments")
.fetch("additionalContacts")
.where()
.in("project_status", projectStatusValues)
.findList();
根据本文档页面中的代码示例,我应该能够做到这一点。 https://ebean-orm.github.io/apidoc/10/io/ebean/FetchConfig.html
解决方案
我使用“*”作为 fetchProperties 并为我工作
Ebean.find(ProjectRequest.class)
.fetch("projectConstructionCosts", "*")
.fetch("attachments", "*")
.fetch("projectRequestComments", "*")
.fetch("additionalContacts", "*")
.where()
.in("project_status", projectStatusValues)
.findList();
推荐阅读
- c++ - 关于异常继承中的语法问题
- excel - 有没有办法在 Azure Blob 存储中将 .xlsx 文件转换为 .csv 文件格式?
- node.js - Lambda 代码适用于 node v8.10 但不适用于 nodejs v10.x
- c - 如何停止打印有条件的字符串?
- python - 如何获得键值等于函数参数?
- python - 如何使用'select_related'从相关(ForeignKey)django模型中接收并非所有字段
- java - 如何从 sql 准备语句中删除单引号
- sql - 查询列包含特定单词的所有列不起作用?
- c++ - 限制整数的 istream 读取宽度
- mysql - 有什么方法可以禁用特定 mysql 数据库的区分大小写选项,直到下次重新启动?