Hi I have been trying to figure this out and cant. If I have the following
class d Class ad extends d d has a reference to t as getT(); class T Class a extends T class p extends T
How can I write a criteria query to go into a. I can do
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); CriteriaQuery query = cb.createQuery(ad.class); Root fromType = query.from(ad.class); cb.equal(fromType.get("t"),get("id"), "test");
Since id is in t that's no problem but lets say bank is in a I get error if I do cb.equal(fromType.get("t").get("bank"), "test");
I can't do cb.equal(fromType.get("t").as(a.class).get("bank"), "test"); either because as returns sum CastFunction which I can't figure out what to do with.
Anyway is this possible seems like would be pretty common use case.
By the way this JPQL query does work "SELECT apd FROM apd apd, t p, a ap WHERE apd.t.id = p.id AND apd.t.id = ap.id"
So just need to get this functionality in criteria api if possible.
|