here's my show case code:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> q = cb.createTupleQuery();
Root<AA> aa = q.from(AA.class);
q.multiselect(aa.get("id").alias("id"),
articolo.get("a").alias("a"),
articolo.get("b").alias("b"),
articolo.get("c").get("t").alias("c"),
articolo.get("d").alias("d"));
System.out.println("RootCount: "+q.getRoots().size());
Query query = em.createQuery(q);
List<Tuple> list = query.getResultList();
Where AA is a mapped Table and c is a CC type item (in wich CC is another mapped table):
well, i'm not allowed to insert an image, so: Tables Schema
c is a foreignkey referencing the table CC
So, the above code will print "RootCount: 1" (only one root) but the resulting query would be something like this:
select aa.id, aa.a, aa.b, cc.t, aa.d from AA aa, CC cc where aa.c=cc.id
so...two roots, but the q.getRoots() report only the one i explicitly have defined.
How can i get the real roots?