android - 使用 greendao 3 从 2 个不同实体获取值

标签 android sqlite orm greendao

问题:如何从 2 个不同的表中获取 2 个值?我正在用 greenDao 替换 android Content Provider。使用内容提供程序,您可以定义 SQL View ,但这对于 greenDao 来说是不可能的。 所以我尝试使用联接,但 greenDao 仅返回一个列表实体。

greenDao 中从 2 个不同实体获取 2 个值的最佳方法是什么?

示例:

 |Table a|                            | Table b |

 | id | descr | b_Id |                |  id   | hues | hex |
 |  1 | place |  1   |                |   1   |   2  | #000|
 |  2 | sea   |  1   |                |   2   |   3  | #111| 
 |  3 | name  |  2   |                ...
 ...                                  ...

如何获得以下对象或类似对象? C c = new C(d.getDecr(), d.getHex());

提前致谢。

最佳答案

考虑使用relations 。如果你有一个对象 a,你可以通过 a.getB() 获取 b。

关于android - 使用 greendao 3 从 2 个不同实体获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38747294/

相关文章:

android - 如何在 Android 上的多个 Activity 之间发送回值

SQLite 查询插入记录如果不存在

python date.min 不会转换回来。为什么?

python - 在 Django 模板中旋转(行/列转置)

android - 无法运行 Android 的位图示例代码

android - OnFling 和其他方法不适用于 ListView 中的 TextView

android - 如何在 Android 的 XML 中创建 'transparent circle inside rectangle' 形状?

Android SQLite 存储纬度和经度为 0

orm - 使用 Doctrine 1.2 进行批量插入

java - 构建 JPA Criteria API 查询 - 按集合中的元素数排序