首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于找不到列,导致房间数据库崩溃

由于找不到列,导致房间数据库崩溃
EN

Stack Overflow用户
提问于 2020-08-13 00:26:53
回答 1查看 612关注 0票数 1

当运行一个查询从房间数据库返回一些数据时,我在API23物理设备上得到了这个崩溃。

LOGCAT

代码语言:javascript
复制
E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_2
java.lang.RuntimeException: Exception while computing database live data.
    at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.IllegalArgumentException: column '`allOrNothing`' does not exist
    at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:333)
    at androidx.room.util.CursorUtil.getColumnIndexOrThrow(CursorUtil.java:108)
    at com.example.persistence.dao.DaoPieChart_Impl$2.call(DaoPieChart_Impl.java:169)
    at com.example.persistence.dao.DaoPieChart_Impl$2.call(DaoPieChart_Impl.java:164)
    at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:90)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
    at java.lang.Thread.run(Thread.java:818) 

我已经看过了表和模型,看不到问题。列名明显存在。

表格

代码语言:javascript
复制
@Entity (tableName = "tableDistortedThinking")
public class TableDistortedThinking {

@PrimaryKey(autoGenerate = true)
private long pkDistortedThinking;

@ColumnInfo(name = "reframingId")
private long fkReframingId;

@ColumnInfo(name = "userId")
private long fkUserId;

@ColumnInfo(name = "allOrNothing")
private Integer allOrNothing;

模型

代码语言:javascript
复制
public class ModelPieChart {

private long userId;
private String twistedName;
private Integer allOrNothing;
private Date workoutDate;
private int DistortedThinkingCount;

查询

代码语言:javascript
复制
@Query("SELECT TableDistortedThinking.allOrNothing, COUNT(TableDistortedThinking.allOrNothing) AS DistortedThinkingCount, TableDistortedThinking.workoutDate, TableDistortedThinking.userId, TableDistortedNames.distortedName AS twistedName " +
        "FROM TableDistortedThinking " +
        "JOIN TableDistortedNames ON TableDistortedThinking.allOrNothing = TableDistortedNames.pkDistortedNameId " +
        "WHERE TableDistortedThinking.workoutDate >= (1000 * strftime('%s', datetime('now', :dateRange)))" +
        "AND TableDistortedThinking.userId = :userId " +
        "GROUP BY TableDistortedNames.distortedName " +

**他们的查询非常长,并且由UNION连接,但只有这一节是真正相关的。任何导致这次崩溃的帮助根用户都会非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-13 21:59:10

此故障是由运行API 25或更低版本的设备上发生的Room错误引起的。在房间版本2.3.0-alpha02中修复。有关更多详细信息,请参阅description in the Google IssueTracker

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63380871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档