android - 房间:选择查询不检索对象的属性
问题描述
我的 android 应用程序提供用户帐户。用户由以下类表示:
public class User implements Parcelable {
@NonNull
@ColumnInfo(name = "user_Id")
@PrimaryKey (autoGenerate = true)
private Long userId;
private String displayedName;
private String email;
private String password;
@ColumnInfo(name = "photo_Id")
private Long photoId;
PhotoId 引用了 Photo :
public class Photo implements Parcelable {
@NonNull
@ColumnInfo(name = "photo_Id")
@PrimaryKey(autoGenerate = true)
private Long photoId;
private String image;
当我保存用户帐户时,我先保存用户,然后保存照片,最后使用生成的照片 ID 更新用户。我使用这些查询:
@Insert
Single<Long> insert(User user);
@Update
Completable update (User user);
@Insert
Single<Long> insert(Photo photo);
根据日志,创建过程似乎 100% 成功,但是当我从数据库中检索用户时
@Query("SELECT * FROM User WHERE email = :userEmail")
Single<User> getUserByEmail(String userEmail);
我检索一个具有空 photoId 的用户。如果用户选择查询未创建完整的 User ,我该如何调试并查找用户 photoId 是否未在 DB por 中正确更新?
更新:问题是即使更新后用户在数据库中也没有 photId。
解决方案
推荐阅读
- android - 备份超过默认配额的安卓应用数据的可行策略
- c++ - C++ 跨平台打印彩色文本
- node.js - 使用axios上传二进制文件?
- swift - 无法在此文件中预览 - 消息发送失败
- javascript - SvelteKit-Firebase 身份验证与 Firebase 谷歌身份验证代码不起作用
- scala - 从1乘到100,为什么第17次是负数?
- php - 为什么 laradock 中的 php.ini 文件没有变化?
- flutter - 创建具有自定义顶栏属性的自定义颤振小部件
- decision-tree - 与水平相比,垂直增长基于树的学习算法有什么区别?
- python - 如何将字符串格式的嵌套列表转换为列表(递归或迭代方式)