public List<Integer>getSubtypeids(List <Integer> typeids,Integer[]parentids){
if (parentids != null && parentids.length>0){
StringBuffer jpql = new StringBuffer();
for(int i=0;i<parentids.length;i++){
jpql.append('?').append(i+1).append(',');
}
jpql.deleteCharAt(jpql.length()-1);
Query query = em.createQuery("select o.typeid from ProductType o where o.parent.typeid in("+jpql.toString()+")");
for(int i=0;i<parentids.length;i++){
query.setParameter(i+1, parentids[i]);
}
typeids.addAll(query.getResultList());
if(query.getResultList() != null && query.getResultList().size()>0){
getSubtypeids(typeids,(Integer[]) query.getResultList().toArray(new Integer[0]));
}
}
return typeids;
}