Why Android Room @Query LIKE is not returning data known to exist

svstackoverflow

My problem: I'm not sure why this Android Room query is not returning results. I thought I understood the proper coding and it seems quite simple. If I pass this same query directly to the same database using SQLiteStudio, I get results.

The calling code (I hardcoded the string 'truth' to test it):

List<Integer> tableIDs = researchDatabase.getCommentsDao().customSearchCommentsTable("truth");

The DAO code (Contained in the CommentsDao):

@Query("SELECT CommentID FROM Comments WHERE Comment LIKE :value")
List<Integer> customSearchCommentsTable(String value);

What I have done: I'm new to Android Room, but I have been using all examples and lessons from Android Developers (developer.android.com) and reviewed and applied many posts here at stackoverflow closely related but I cannot get any results to return. When I step through the code, the actual Android Room code does not seem to be binding the variable string to the statement though I can see the argument string being identified and passed properly, which isn't code that I have written, or at least I never see the resulting binding string with my variable data, I only see this:

SELECT CommentID FROM Comments WHERE Comment LIKE ?

What my goal is: This is actually the first step to creating a query to handle a multiple LIKE query similar to this, which I think will require a @RawQuery setup. Right now, I cannot get the simple thing to work.

What happens in the @Query wrapper: I realize I may be naive and wrong here, but below I can see the argument and statement both get passed, but it does not appear as if the "_statement.bindString" is actually binding the ":value" ('truth') to the statement and is returning 0 results.

Room Query Annotation code

svstackoverflow

This is the solution provided by the Android Room development team:

@Query("SELECT CommentID FROM Comments WHERE Comment LIKE '%' || :value || '%'")
List<Integer> customSearchCommentsTable(String value);

The irony is that the development team could not get their posted code example to work. By the time they responded I had already created a workaround using a @RawQuery method to create the proper SQL syntax.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Android room persistent: AppDatabase_Impl does not exist

From Java

Android Room - Select query with LIKE

From Dev

Why is my LIKE query not returning any records in Microsoft Access 2013 only?

From Dev

Why is NHibernate not returning any data?

From Dev

SQL - query returning rows that presumably do not exist

From Dev

Android SQLite query not returning data after insert

From Dev

Why this query returning -1?

From Dev

Query Not Returning All Data

From Dev

Why Neo4j query is not returning wright data with first query?

From Dev

Android SQLite Like query

From Dev

Why is my MySQL search query returning column names and data?

From Dev

Returning Single<Long> on @Insert in Android Room doesn't work

From Dev

Why Android Room @Query LIKE is not returning data known to exist

From Dev

Android room persistent: AppDatabase_Impl does not exist

From Dev

Query is not returning the data

From Dev

Why inside the then() the data exist, and out side doesn't - Axios returning undefined

From Dev

Why is my query not working for room.slug

From Dev

FQL Query not returning all data

From Dev

Why query is not returning value

From Dev

sql query, can exist LIKE and == Operators?

From Dev

Why this query returning -1?

From Dev

LIKE query not working in android

From Dev

Query Returning All Data In Table

From Dev

Why is my MySQL search query returning column names and data?

From Dev

Why I obtain this exception into a Spring Data JPA native SQL query? IllegalArgumentException: Parameter with that position [2] did not exist

From Dev

Postgresql: Query returning incorrect data

From Dev

MySql query returning all the data

From Dev

Laravel Database Query Not Returning Data

From Dev

query not returning the right data

Related Related

  1. 1

    Android room persistent: AppDatabase_Impl does not exist

  2. 2

    Android Room - Select query with LIKE

  3. 3

    Why is my LIKE query not returning any records in Microsoft Access 2013 only?

  4. 4

    Why is NHibernate not returning any data?

  5. 5

    SQL - query returning rows that presumably do not exist

  6. 6

    Android SQLite query not returning data after insert

  7. 7

    Why this query returning -1?

  8. 8

    Query Not Returning All Data

  9. 9

    Why Neo4j query is not returning wright data with first query?

  10. 10

    Android SQLite Like query

  11. 11

    Why is my MySQL search query returning column names and data?

  12. 12

    Returning Single<Long> on @Insert in Android Room doesn't work

  13. 13

    Why Android Room @Query LIKE is not returning data known to exist

  14. 14

    Android room persistent: AppDatabase_Impl does not exist

  15. 15

    Query is not returning the data

  16. 16

    Why inside the then() the data exist, and out side doesn't - Axios returning undefined

  17. 17

    Why is my query not working for room.slug

  18. 18

    FQL Query not returning all data

  19. 19

    Why query is not returning value

  20. 20

    sql query, can exist LIKE and == Operators?

  21. 21

    Why this query returning -1?

  22. 22

    LIKE query not working in android

  23. 23

    Query Returning All Data In Table

  24. 24

    Why is my MySQL search query returning column names and data?

  25. 25

    Why I obtain this exception into a Spring Data JPA native SQL query? IllegalArgumentException: Parameter with that position [2] did not exist

  26. 26

    Postgresql: Query returning incorrect data

  27. 27

    MySql query returning all the data

  28. 28

    Laravel Database Query Not Returning Data

  29. 29

    query not returning the right data

HotTag

Archive