Android Room Persistence Library - How to find entities with ids contained in list of ids?

后端 未结 2 1328
囚心锁ツ
囚心锁ツ 2021-01-11 13:54

I am trying to do the following query in my DAO.

   @Query(\"SELECT * FROM objects WHERE obj_id IN :ids\")
   List queryObjects(List

        
                      
相关标签:
2条回答
  • 2021-01-11 14:24

    You need parentheses:

    @Query("SELECT * FROM objects WHERE obj_id IN (:ids)")
    List<Object> queryObjects(List<String> ids);
    

    (and FWIW, I filed an issue to try to get a better error message here)

    0 讨论(0)
  • 2021-01-11 14:46

    You can set either list of input or array of input.

    and then make a query like this

    e.g. String[] ids or List ids

    Query = @Query("select * from objects where obj_id in (:ids)")

    0 讨论(0)
提交回复
热议问题