【发布时间】:2018-09-12 21:56:34
【问题描述】:
我在 Apache Ignite 中创建了一个架构,如下所示:
---------------------------------------------
EmpId | EmpName | HomeZip | OfficeZip| Dept |
---------------------------------------------
1 | Sam | 98123 | 98123 | A |
---------------------------------------------
2 | Jack | 98123 | 98123 | B |
---------------------------------------------
3 | John | 98124 | 98123 | A |
---------------------------------------------
4 | Kim | 98124 | 98123 | C |
---------------------------------------------
如何进行以下查询:
- 查找 A 部门员工的所有详细信息。
- 查找 homeZip 与 OfficeZip 相同的员工的所有详细信息。
如何使用 SQLQuery 执行此操作并将响应映射到模型类
class Employee{
private Integer empId;
private String empName;
private String homeZip;
private String officeZip;
private String dept;
}
我尝试按如下方式查询它,但对我来说有错误:
//For finding out employee in list of departments
SqlQuery sql = new SqlQuery(Employee.class, "dept in (?)).setArgs(deptList);
//For finding out employee with same zip for office and home:
SqlQuery sql = new SqlQuery(Employee.class, "homeZip = officeZip");
【问题讨论】:
-
好吧,看起来您只需要编写几个非常简单的 SQL 查询。你有什么尝试吗?您是否有具体问题需要帮助?
-
是的,请查看问题中的更新。我不确定这是否是编写 IN 子句查询的正确方法。它出现“无法远程运行地图查询”的错误
-
请提供整个异常堆栈跟踪。
-
看起来围绕基于“IN 子句”的查询存在一些问题。我正在寻找类似的东西:apache-ignite-users.70518.x6.nabble.com/…
-
自那以后没有任何改变。不过,您可以用 JOIN 替换 IN,请参见此处的第 2 点:apacheignite-sql.readme.io/docs/…