Hello,
I have a subclass Case of an AbstractCase defined like so:
@Entity@DiscriminatorValue(value = "1")public class Case extends AbstractCase {@ManyToOne@JoinColumn(name = "parentcaseid")Block block; // discriminator "2"...}
A query like this:Query query = Ebean.find(Case.class).where()...
produces SQL like this:select t0.abstractcasetype as c0, t0.caseid as c1 ..., t2.abstractcasetype as c18, t2.caseid as c19 from public.cases t0left outer join public.cases t2 on t2.caseid = t0.parentcaseid where t0.abstractcasetype = '1' and t2.abstractcasetype = '2' ...
Since Case.block is nullable, the left join is proper, but the discriminator test in the where phrase filters out all Cases where the block is null. It seems the where phrase should be something like:where t0.abstractcasetype = '1' and (t2.abstractcasetype = '2' or t2.caseid is null)
I can get around this problem by turning off auto fetch and selecting what I need.
Same as http://www.avaje.org/bugdetail-408.html
The workaround I mentioned works for queries, but not for find:
Ebean.find(MyBean.class, 1234)
since there is no control over the query. This elevates the severity of this bug for me.