Dear group,iam trying to get some objects of the type "Card" from my database.A Card has a @OneToMany Annotation to Tags.Now iam trying to fetch some cards from the database, which have a specific search term in their keyword OR description OR (if they have any) the search term in their associated tags:
List<Card> cardList = Ebean.find(Card.class).fetch("tags")
.fetch("categories").where().eq("categories.id", id)
.disjunction().add(Expr.like("keyword", "%" + text + "%"))
.add(Expr.like("description", "%" + text + "%"))
.add(Expr.like("tags.text", "%" + text + "%"))
.orderBy("keyword").findList();The resulting SQL query is:
select distinct t0.id c0, t0.keyword c1, t0.description c2, t0.revision c3, t0.created_date c4, t0.modified_date c5
, t1.id c6, t1.title c7, t1.revision c8, t1.created_date c9, t1.modified_date c10
from card t0
left outer join card_category t1z_ on t1z_.card_id = t0.id
left outer join category t1 on t1.id = t1z_.category_id
join card_category u1z_ on u1z_.card_id = t0.id
join category u1 on u1.id = u1z_.category_id
join tag u2 on u2.card_id = t0.id
where u1.id = 2 and (t0.keyword like '%FU%' or t0.description like '%FU%' or u2.text like '%FU%' )
order by t0.keywordThe problem with this is, that i dont get the cards in the results which dont have any associated tags.
If execute this query manually in my DBMS and alter "join tag u2" to "left join tag u2", i also get cards which haven't any tags.
Is there any way to enforce a LEFT JOIN in ebean or can i enforce this somehow else?Thanks
This looks like a known bug that Daryl hit a while back.
I suspect Daryl used raw sql to get around this issue in the meantime.
Hello Daryl,could you please share how you use raw sql to get around this issue?
Hey Didier,I'm stuck at the same problem. I need a disjunction and the paging function.Could you please tell me how you solved the problem?Thank you
Is there a fix for this yet? I just ran into the same issue.
--
---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.