Supposed I have an object
class Person {
String firstName;
String lastName;
... other fields...
}
and a database that contains
@Entity
class DatabaseTable {
String firstName;
String lastName;
... other unrelated fields from person...
}
now in my Dao, I have
@Query("SELECT * FROM DatabaseTable WHERE " +
" firstName = :firstName AND lastName = :lastName")
List<DatabaseTable> getAll(String firstName, String lastName);
I have list that I want to query DatabaseTable from.
Person("Apple", "Kohn", ...)
Person("Benny", "Lorie", ...)
Person("Cindy", "May", ...)
...
How would i go about extracting the Database table efficiently? It don't seem right to call the dao for every Person in my list.
EDIT:
I like to know how to use a single query to retrieve a list of results.
I know that under the hood Room uses ContentValue to loop though an entity list. Is there a way for us to create our own contentValue to pass into Room?
Is something like the following possible?
getAllWithPairs( List<String> firstNames, List<String> lastNames);