문제

I have a play! framework project that uses ebean for models management. I have 4 models, A B C D. A and B is oneToMany, B and C is OneToMany, B and D is One To Many. Now I want a list of A that is linked with all related B C D.

What I have now is

A.find.fetch("Bs", new FetchConfig().query()).fetch("Bs.Cs", "Bs.Ds", new FetchConfig().query()).findList();

But the performance is really poor and according to the sql log the sql queries are not joined as I want. Is there any way that I can use query join for all of them? (i.e. select all A B C D with 4 queries and join them locally instead of separate queries for each B?)

도움이 되었습니까?

해결책

javadoc for new FetchConfig.query() ... Eagerly fetch the beans in this path as a separate query (rather than as part of the main query).

That is, you should remove the FetchConfig.query() if you want to use a SQL join rather than a separate query.

That said, Ebean will not return A B C D in a single query as that would result in a cartesian product and it will automatically break up the query to avoid that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top