Android 文件室:选择查询不检索对象的属性
我的android应用程序提供用户帐户。用户由以下类表示:Android 文件室:选择查询不检索对象的属性,android,android-room,Android,Android Room,我的android应用程序提供用户帐户。用户由以下类表示: public class User implements Parcelable { @NonNull @ColumnInfo(name = "user_Id") @PrimaryKey (autoGenerate = true) private Long userId; private String displayedName; private String email; priv
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;
照片ID引用照片:
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为空的用户。
如果用户select查询没有创建完整的用户,我如何调试这个问题并发现用户photoId在DB por中没有正确更新
更新:问题是,即使在更新之后,用户数据库中也没有photId。用于调试数据库在创建两个photoId之后,您是否手动将photoId分配给用户?是的,在用户和照片创建之后,我使用生成的photoId更新用户。谢谢Rasel,我可以看到,这是没有正确更新photoId的用户。我编辑了我的第一条消息。你能分享一下代码吗?代码显示你在插入照片后是如何获得照片id的?另外,用户更新代码/查询是什么样子的?