Reputation: 3128
I'm trying to create search interface via ORMLite in Android. There are 3 tables created, that are making many-to-many relationship. (Recipe >> RecipesForTag << Tag)
tagQueryBuilder.where()
.like(Tag.COLUMN_NAME, "%" + text + "%");
recipesForTagQueryBuilder
.joinOr(tagQueryBuilder);
recipeQueryBuilder
.joinOr(recipesForTagQueryBuilder)
...other joins
.where()
.like(Recipe.COLUMN_TITLE, "%" + text + "%");
PreparedQuery<Recipe> preparedQuery = recipeQueryBuilder.prepare();
return recipeDao.query(preparedQuery);
When I'm not using line with .joinOr(recipesForTagQueryBuilder)
everything is working fine. So what am I doing wrong?
Upvotes: 1
Views: 193
Reputation: 3128
OK my bad. The only thing that was bad was using joinOr while I needed leftJoinOr... The question has one main problem: when middle table is empty no result will be find (also when ...other joins is nonempty). So result is simple:
recipesForTagQueryBuilder
.leftJoinOr(tagQueryBuilder);
recipeQueryBuilder
.leftJoinOr(recipesForTagQueryBuilder)
Upvotes: 1