当我拥有一个具有嵌入式和一对多关系的POJO时,我试图解决这个问题,并且自动生成的代码为光标选择了不合适的列索引。问题在于它将混淆“身份”和“扫描”中的列,并从“连接”中将“扫描”值设置为“身份”的值。
我已经检查了The field's same name issue in the tables, when join tables in ROOM的答案,但似乎无法解决问题,因为它无法为POJO生成可编译的代码。 我有两个类,“扫描”和“身份”,它们是通过
检索的@Query("SELECT * FROM scans JOIN identities on scans.identity_id = identities.rid WHERE scans.id IN (:ids) AND scans.deleted_at IS NULL ORDER BY scans.updated_at DESC")
@Transaction
Flowable<List<ScanAndIdentity>> findAllWithIdentity(long[] ids);
还有POJO:
public class ScanAndIdentity {
@Embedded
public Scan scan;
@Relation(parentColumn = "identity_id", entityColumn = "rid", entity =
Identity.class)
public List<Identity> identities;
}
如何解决此问题?我尝试在Embedded中使用前缀,但这也给出了错误
Not sure how to convert a Cursor to this method's return type (*.pojo.ScanAndIdentity)