I'm trying to get rid of left join fetch in one of our HQLs:
query = select r,f,c from ClassPos r, ClassFal f ,ClassCon c left join fetch c.ClassReg where
DB contains this data satisfying above where clause:
ClassPos has 1 row, ClassFal has 2 rows, ClassCon has 1 row and ClassReg has 1 row.
We're using scrollable results to scroll through the results:
ScrollableResults results = query.scroll(ScrollMode.SCROLL_INSENSITIVE); i =0 while(results.next()) { i++ } print(i); We're expecting the resultset to have 2 rows but it's returning 1(i=1). When we run the SQL, we can clearly see 2 rows in the DB.
Now when we get rid of left join fetch, we see the result set has 2 rows:
query = select r,f,c from ClassPos r, ClassFal f ,ClassCon c where <clause> Tried looking up various places but can't get a reason. Can somebody explain this behaviour?
|