You can use below programmatic approach to solve this problem.Create a view criteria progarametically and set attribute value as bind variable.
ViewObjectImpl view = this.getNsSentenceGroupVO();
ViewCriteria vc = view.createViewCriteria();
vc.setName("INCriteria");
String inClause = "IN "+groupNames;
ViewCriteriaRow criteriaRow = vc.createViewCriteriaRow();
criteriaRow.setAttribute(" GroupName", inClause);
vc.addElement(criteriaRow);
view.applyViewCriteria(vc, true);
view.executeQuery();
System.out.println(view. getEstimatedRowCount());
This groupNames is coming from below method. It will iterate a ArrayList and give u a single string with well formatted query as string.
public void loadRemovalGroups(){
//getGroupsForRemove
String groups="(";
ArrayList data=getSelectedGroups();
if(!data.isEmpty()){
Iterator itr = data.iterator();
while(itr.hasNext()){
String a = (String)itr.next();
groups=groups+"'"+a+"'"+",";
}
}
if(groups.length() > 2){
groups=groups.substring(0, groups.length()-1)+")";
}
System.out.println("groups -> "+groups);
}
Comments
Post a Comment