【发布时间】:2018-02-20 09:01:36
【问题描述】:
我决定在我当前的应用程序中使用 Room。
发现当前架构中的一列没有类型,并且 Room 在迁移时生成 IllegalStateException。
java.lang.IllegalStateException: Migration didn't properly handle item.
Expected:
TableInfo{name='item', columns={optional_modifiers=Column{a_type=Column{name='a_type', type='BLOB', notNull=false, primaryKeyPosition=0}...}
Found:
TableInfo{name='item', columns={optional_modifiers=Column{a_type=Column{name='a_type', type='', notNull=false, primaryKeyPosition=0}...}
建表的Sql脚本:
"create table item ("
" id text primary key," +
" a_type, "
//...
")
实体类:
@Entity(tableName = "item")
data class Item(
@PrimaryKey
val id: String?,
val a_type: String? // actually I used several types, but none of them is worked
)
有没有办法解决这个问题?
【问题讨论】:
-
能否请您分享您的新实体类和旧架构?
-
错误表示您的迁移中发生了数据类型不匹配。
-
@Pinakin 是的,我看到它是类型不匹配。但是房间里没有“空”的类型
-
分享我用@Entity注释的类
-
你能分享你用@Entity注释的Entity类吗?
标签: android sqlite android-sqlite android-room