Set rootAlias outside loop
Add rootAlias to Criteria where clauses