I am trying to create a dynamic query using input and working with the user. My code I created a list of criteria, for example:
List<Criteria> criterias = new ArrayList<Criteria>();
and added criteria to this list. And its addition is successful. Now I want to make an operator between each criterion.
Criteria criteria = new Criteria().andOperator(criterias.get(0), criterias.get(1));
It works fine But my input is not fixed, so I want it to add dynamically, I tried as
for(int i=0;i<criterias.size();i++)
Criteria criteria = new Criteria().andOperator(criterias.get(i));
where am i out
source
share