@Dao interface PostDao { @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertPost(post: PostEntity) @Query("SELECT * FROM post_entity") suspend fun getAll(): List<PostEntity> } 编译报错 The query returns some columns [path, content, time, likeCount, id] which are not used by java.lang.Object. You can use @ColumnInfo annotation on the fields to specify the mapping. You can annotate the method with @RewriteQueriesToDropUnusedColumns to direct Room to rewrite your query to avoid fetching unused columns. You can suppress this warning by annotating the method with @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH). Columns returned by the query: path, content, time, likeCount, id. Fields in java.lang.Object: . public abstract java.lang.Object getAll(@org.jetbrains.annotations.NotNull ^
时间: 2023-06-23 22:09:54 浏览: 155
tomcat启动debug.txt
对于这个问题,可能是由于你的查询返回了一些列,但在 Java.lang.Object 中没有使用。你可以使用 @ColumnInfo 注释在字段上指定映射,并使用 @RewriteQueriesToDropUnusedColumns 注释方法来重写查询以避免获取未使用的列。你还可以使用 @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) 注释来抑制此警告。查询返回的列是:path、content、time、likeCount 和 id。请检查一下你的代码并按照提示进行修改。
阅读全文