0

While running this code:

note = noteDAO.queryForFirst(
    noteDAO.queryBuilder().where().notIn("id",
        noteStateDAO.queryBuilder().distinct().selectColumns("noteId")
        .prepare())
    .prepare());

... I've got following exception:

Problems executing Android query: SELECT * FROM `notes` WHERE `id` NOT IN 
     (MappedStatement: SELECT DISTINCT `noteId` FROM `note_states`)

Any ideas of what is MappedStatement in that SQL?

2 Answers 2

1

You've solved you problem it seems, but I thought I'd provide some more information.

The Where.notIn(...) method takes either objects or a QueryBuilder argument. By doing a prepare(), it turns it into a MappedQuery which was passed as an Object unfortunately.

As you mention, if your remove the prepare(), it will use the QueryBuilder arguments. See the javadocs for notIn(String, QueryBuilder).

I've added better checking against passing in a prepared query in ORMLite version 4.43.

Sign up to request clarification or add additional context in comments.

Comments

0

Ok, found by myself. No need to prepare the inner subselect query:

note = noteDAO.queryForFirst(
    noteDAO.queryBuilder().where().notIn("id",
        noteStateDAO.queryBuilder().distinct().selectColumns("noteId")
        /*.prepare()*/)
    .prepare());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.