Android 表问题之间的房间关系

Android 表问题之间的房间关系,android,android-room,Android,Android Room,我非常熟悉表之间的关系,尤其是使用SQLite时。 最近,我搬进了一间考虑MVVM清洁体系结构的房间,在建立关系的过程中,我遇到了很多困惑 为了简单起见,我将获取Github repo列表并将其存储在DB using Room中 这里是JSON [ { “作者”:“idealvin”, “名称”:“公司”, “阿凡达”:https://github.com/idealvin.png", “url”:”https://github.com/idealvin/co", “描述”:“一个优雅、高效的

我非常熟悉表之间的关系,尤其是使用SQLite时。 最近,我搬进了一间考虑MVVM清洁体系结构的房间,在建立关系的过程中,我遇到了很多困惑

为了简单起见,我将获取Github repo列表并将其存储在DB using Room中

这里是JSON

[
{
“作者”:“idealvin”,
“名称”:“公司”,
“阿凡达”:https://github.com/idealvin.png",
“url”:”https://github.com/idealvin/co",
“描述”:“一个优雅、高效的C++基础库,用于Linux、Windows和MAC。”
“语言”:“C++”,
“语言颜色”:“f34b7d”,
“星星”:635,
“叉子”:82,
“星星”:130,
“建筑商”:[
{
“用户名”:“idealvin”,
“href”:”https://github.com/idealvin",
“阿凡达”:https://avatars1.githubusercontent.com/u/12691466"
},
{
“用户名”:“弗雷德里克vs贾”,
“href”:”https://github.com/frederick-vs-ja",
“阿凡达”:https://avatars3.githubusercontent.com/u/23228989"
},
{
“用户名”:“FrankHB”,
“href”:”https://github.com/FrankHB",
“阿凡达”:https://avatars0.githubusercontent.com/u/1857647"
}
]
},
{
“作者”:“Alysaxuu”,
“名称”:“流动”,
“阿凡达”:https://github.com/alyssaxuu.png",
“url”:”https://github.com/alyssaxuu/flowy",
“description”:“创建流程图的最小javascript库”✨",
“语言”:“JavaScript”,
“语言颜色”:“f1e05a”,
《星星》:1841年,
“叉子”:58,
“星星”:459,
“建筑商”:[
{
“用户名”:“alyssaxuu”,
“href”:”https://github.com/alyssaxuu",
“阿凡达”:https://avatars3.githubusercontent.com/u/7581348"
},
{
“用户名”:“artmsilva”,
“href”:”https://github.com/artmsilva",
“阿凡达”:https://avatars3.githubusercontent.com/u/347490"
}
]
}

]
一种修复方法是删除此项:

@SerializedName("builtBy")
@Expose var builtByList: List<BuiltByEntity>? = null
@SerializedName(“builtBy”)
@Expose var builtByList:List?=null
从GithubEntity。插入GithubEntity项,并按其id插入BuiltByEntity

你们看,这是令人讨厌的。注意,在房间里并没有插入关系的原生方式。阅读问题和答案以获得最佳实践

更新:


也请阅读本文:

Hi@Sina,我在使用SQLite的时候经常这样做。我去了那个帖子(上面突出显示)我只是想确认一下!!据我所知,它还没有改变。我们都承受着同样的痛苦:)我刚刚发现在这个问题上对我很有帮助的东西。我更新了我的答案。