Page 1 of 1
About Question enthuware.oce-jpad.v6.2.579 :
Posted: Mon Sep 26, 2016 5:19 am
by tioola
This question is saying that there are 2 Customers and each Customer has 3 Orders, the correct question is saying that list will contain 12 , In my understand it should be 6 2x3=6
Am I missing something?
THanks.
Re: About Question enthuware.oce-jpad.v6.2.579 :
Posted: Mon Sep 26, 2016 8:23 pm
by admin
Each customer has three orders. So there are 6 orders.
-Paul.
Re: About Question enthuware.oce-jpad.v6.2.579 :
Posted: Mon Jul 03, 2017 1:24 pm
by himaiMinh
In the explanation :
The above code can be fixed to return only those customers who have at least one order by added a where clause like this:
cq.where(cb.equal(custRoot, orderRoot.get("customer")));
I guess this can be this:
"cq.where(cb.equal(custRoot, orderRoot.get("customer"))).distinct(true);
to avoid duplicates.