Room “Not sure how to convert a Cursor to this method's return type”: which method?

后端 未结 20 1441
遇见更好的自我
遇见更好的自我 2020-12-14 14:15
Error:Not sure how to convert a Cursor to this method\'s return type
Error:Execution failed for task \':app:compileDebugJavaWithJavac\'.
Compilation failed; see the          


        
20条回答
  •  长情又很酷
    2020-12-14 15:15

     class IdAndFullName {
         public int uid;
         @ColumnInfo(name = "full_name")
         public String fullName;
     }
     // DAO
     @Query("SELECT uid, name || lastName as full_name FROM user")
     public IdAndFullName[] loadFullNames();
    

    If there is a mismatch between the query result and the POJO, Room will give you this error message.

    Or if you are using @SkipQueryVerification, you will also get this error.

提交回复
热议问题