{
  "id": "android/room-invalid-cursor-query",
  "signature": "android.database.sqlite.SQLiteException: Invalid column type (code 0): Cannot read column 'timestamp' as a long (code 0) at /path/to/RoomDatabase.kt:123",
  "signature_zh": "android.database.sqlite.SQLiteException：无效的列类型（代码 0）：无法将列 'timestamp' 读取为 long 类型（代码 0），位于 /path/to/RoomDatabase.kt:123",
  "regex": "android\\.database\\.sqlite\\.SQLiteException.*Invalid column type.*Cannot read column.*as a",
  "domain": "android",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Room's generated DAO implementation tries to read a column with a type that does not match the expected Java/Kotlin type, often due to a schema mismatch or incorrect converter.",
  "root_cause_type": "generic",
  "root_cause_zh": "Room 生成的 DAO 实现尝试读取与预期 Java/Kotlin 类型不匹配的列，通常是由于模式不匹配或转换器错误。",
  "versions": [
    {
      "version": "Room 2.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Change the field type in the entity to match the error message, e.g., change long to String",
      "why_fails": "The error indicates an actual schema mismatch; changing the type without updating the database version and migration leads to a crash or data loss.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Delete the app data and reinstall without running migrations",
      "why_fails": "This destroys user data and is not suitable for production; it only works if the schema was never properly migrated.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add @Ignore annotation to the problematic field",
      "why_fails": "Room will ignore the field entirely, potentially breaking queries that depend on it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check the entity and database version. If the column type changed, create a migration. Example: static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL(\"ALTER TABLE users ADD COLUMN timestamp INTEGER NOT NULL DEFAULT 0\"); } }; Then add .addMigrations(MIGRATION_1_2) to the Room database builder.",
      "success_rate": 0.9,
      "how": "Check the entity and database version. If the column type changed, create a migration. Example: static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL(\"ALTER TABLE users ADD COLUMN timestamp INTEGER NOT NULL DEFAULT 0\"); } }; Then add .addMigrations(MIGRATION_1_2) to the Room database builder.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the column type is correct but the converter is wrong, verify the TypeConverter. Example: @TypeConverter public static Long fromTimestamp(Long value) { return value == null ? null : value; } @TypeConverter public static Long dateToTimestamp(Long value) { return value; } Ensure both converters are symmetric and registered in @Database(entities = {...}, version = X, exportSchema = true).",
      "success_rate": 0.85,
      "how": "If the column type is correct but the converter is wrong, verify the TypeConverter. Example: @TypeConverter public static Long fromTimestamp(Long value) { return value == null ? null : value; } @TypeConverter public static Long dateToTimestamp(Long value) { return value; } Ensure both converters are symmetric and registered in @Database(entities = {...}, version = X, exportSchema = true).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use fallbackToDestructiveMigration() in the database builder for development: Room.databaseBuilder(context, AppDatabase.class, \"db-name\").fallbackToDestructiveMigration().build(); This recreates the database if no migration is found, but destroys data.",
      "success_rate": 0.7,
      "how": "Use fallbackToDestructiveMigration() in the database builder for development: Room.databaseBuilder(context, AppDatabase.class, \"db-name\").fallbackToDestructiveMigration().build(); This recreates the database if no migration is found, but destroys data.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check the entity and database version. If the column type changed, create a migration. Example: static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL(\"ALTER TABLE users ADD COLUMN timestamp INTEGER NOT NULL DEFAULT 0\"); } }; Then add .addMigrations(MIGRATION_1_2) to the Room database builder.",
    "If the column type is correct but the converter is wrong, verify the TypeConverter. Example: @TypeConverter public static Long fromTimestamp(Long value) { return value == null ? null : value; } @TypeConverter public static Long dateToTimestamp(Long value) { return value; } Ensure both converters are symmetric and registered in @Database(entities = {...}, version = X, exportSchema = true).",
    "Use fallbackToDestructiveMigration() in the database builder for development: Room.databaseBuilder(context, AppDatabase.class, \"db-name\").fallbackToDestructiveMigration().build(); This recreates the database if no migration is found, but destroys data."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/training/data-storage/room",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}