我正在尝试使用空间并写下以下内容:
@Entity(foreignKeys = arrayOf(ForeignKey(entity = Category::class,
parentColumns = arrayOf("id"), childColumns = arrayOf("parentId"))))
data class Category (
val type: Byte,
val name: String,
val description: String,
var parentId: Long? = null,
var remoteId: Long? = null,
@PrimaryKey(autoGenerate = true)
val id: Long = 0L,
@Relation(parentColumn = "id", entityColumn = "parentId")
var subcategories: List<Category>? = null
)
但是我得到了这个:
Error:Execution failed for task ':app:kaptDebugKotlin'.
> Internal compiler error. See log for more details
以及更多详细信息:
java.lang.IllegalStateException: failed to analyze:
java.lang.StackOverflowError
at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57)
也许有人面临这个问题(因为没有子类别字段一切都很好)。
谢谢!
最佳答案
引用the documentation for @Relation
:
Note that
@Relation
annotation can be used only in Pojo classes, an Entity class cannot have relations.
理想情况下,您会得到比 StackOverflowError 更好的构建错误,但您应该得到某种形式的构建错误。
关于android - 构建房间期间出现 StackOverflowError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50317853/