【问题标题】:StackOverflowError during build room构建房间期间的 StackOverflowError
【发布时间】:2018-05-13 15:42:28
【问题描述】:

我正在尝试使用房间并写下这个:

@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)

也许有人会遇到这个问题(因为没有子类别字段都可以正常工作)。

谢谢!

【问题讨论】:

    标签: android database kotlin android-room


    【解决方案1】:

    引用the documentation for @Relation:

    注意@Relation注解只能在Pojo类中使用,Entity类不能有关系。

    理想情况下,您会得到比StackOverflowError 更好的构建错误,但您应该会收到某种形式的构建错误。

    【讨论】:

      猜你喜欢
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      • 2013-04-10
      • 2012-11-14
      • 2022-01-05
      相关资源
      最近更新 更多